Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WM_DEVICECHANGE Problem Pin
Ozer Karaagac6-Mar-11 21:48
professionalOzer Karaagac6-Mar-11 21:48 
GeneralRe: WM_DEVICECHANGE Problem Pin
goldenrose96-Mar-11 21:54
goldenrose96-Mar-11 21:54 
GeneralRe: WM_DEVICECHANGE Problem Pin
Ozer Karaagac6-Mar-11 22:09
professionalOzer Karaagac6-Mar-11 22:09 
GeneralRe: WM_DEVICECHANGE Problem Pin
goldenrose96-Mar-11 22:23
goldenrose96-Mar-11 22:23 
GeneralRe: WM_DEVICECHANGE Problem Pin
Ozer Karaagac6-Mar-11 22:43
professionalOzer Karaagac6-Mar-11 22:43 
GeneralRe: WM_DEVICECHANGE Problem Pin
goldenrose96-Mar-11 23:43
goldenrose96-Mar-11 23:43 
QuestionSockets and Port number Pin
sawerr5-Mar-11 23:09
sawerr5-Mar-11 23:09 
AnswerRe: Sockets and Port number Pin
Bill SerGio, The Infomercial King6-Mar-11 0:50
Bill SerGio, The Infomercial King6-Mar-11 0:50 
Your question is an excellent question. Most books and articles that talk about sockets FAIL to explain this and question goes to the heart of all real world examples of writing socket code.
I will answer your question with a real world example that I worked on recently.
Let's say that you want to show stock data about a stock or group of stocks that changes every second in a web page and that the source of this data is some TCP server that you would connect to and receive a callback from every second in the form of strings. So let's say the user select a stock symbol like "IBM" and wants to see the price and volume traded of IBM stock in their web browser every second. Another user might want to see the value of a different stock symbol like "ACL" for Alcon, Inc.
How many IP addresses and Ports we would need? As you know we must use web Sockets to connect from a web page to a TCP Server--BUT there is another problem--none of the stock alert data servers have implemented the Web Sockets protocol handshake so we will need a web socket proxy between the web page and the Data Server. There are 2 samples of web Sockets Servers posted here on CodeProject that we can use.
If we put the ip address and port INSIDE the web page and connect to a Web Sockets Server then that web sockets server must spin off a thread that will in side each thread open a TCP connection to Data Server on a given ip address and port. The data from the thread received from the data server will be sent to the web socket server and then back to the client web browser that requested the data and NOT to any other browsers. Each browser on connecting to the web socket server passes in a "settings string" like say the stock symbol so that 2,000 different web browsers would see different data for 2,000 different stock symbols where each browser would have a datagrid displaying say hundreds of rows of stock data per second for that one symbol they requested.
When you set up this scenario--trial and error are good ways to learn socket programming--you will quickly realize that the amount of data that the web sockets data has to return is huge and the Data Server is passing the data for all 2,000 connected web browsers back to one place, namely the web sockets server--you could write a queue manager but that can't handle this kind of volume.
Here is the solution and answer to you question. You create a web service to return different port numbers to the web page. The web page sits on the server along with your web sockets server so the web page will first send a request to the web service and the web service will launch a NEW INSTANCE of the web sockets server with the SAME IP Addresses BUT a new port number and the web service will send that port number corresponding to the instance of the web sockets server it launched to the web page page that will then make a web socket connection via TCP to the new instance of the web sockets server. In this way you will have a new instance of Web Sockets server which is just a console app running for EACH web browser that is connected where each web browser has a different port number specified. You can easily connect 2,000 web browsers this way.
In summary, the ip addresses can be the same but the port numbers must change.Cool | :cool:
http://www.KabbalahCode.com

AnswerRe: Sockets and Port number Pin
Andrew Brock6-Mar-11 0:54
Andrew Brock6-Mar-11 0:54 
GeneralRe: Sockets and Port number Pin
sawerr6-Mar-11 1:36
sawerr6-Mar-11 1:36 
GeneralRe: Sockets and Port number Pin
Andrew Brock6-Mar-11 2:01
Andrew Brock6-Mar-11 2:01 
AnswerRe: Sockets and Port number Pin
Bill SerGio, The Infomercial King6-Mar-11 2:14
Bill SerGio, The Infomercial King6-Mar-11 2:14 
Questionhelp with tcl/tk in C Pin
basel-bh5-Mar-11 20:53
basel-bh5-Mar-11 20:53 
Questioncase statement in DLGPROC [SOLVED] Pin
goldenrose95-Mar-11 16:36
goldenrose95-Mar-11 16:36 
AnswerRe: case statement in DLGPROC Pin
Andrew Brock5-Mar-11 17:55
Andrew Brock5-Mar-11 17:55 
QuestionWM_COMMAND [SOLVED] Pin
goldenrose95-Mar-11 5:08
goldenrose95-Mar-11 5:08 
AnswerRe: WM_COMMAND Pin
Michael Dunn5-Mar-11 6:58
sitebuilderMichael Dunn5-Mar-11 6:58 
AnswerRe: WM_COMMAND Pin
CPallini5-Mar-11 7:37
mveCPallini5-Mar-11 7:37 
QuestionMoving GDI+ objects question Pin
csrss5-Mar-11 2:13
csrss5-Mar-11 2:13 
AnswerRe: Moving GDI+ objects question Pin
Niklas L5-Mar-11 2:42
Niklas L5-Mar-11 2:42 
GeneralRe: Moving GDI+ objects question Pin
csrss5-Mar-11 3:36
csrss5-Mar-11 3:36 
GeneralRe: Moving GDI+ objects question Pin
Niklas L5-Mar-11 5:39
Niklas L5-Mar-11 5:39 
GeneralRe: Moving GDI+ objects question Pin
csrss5-Mar-11 6:16
csrss5-Mar-11 6:16 
AnswerRe: Moving GDI+ objects question Pin
Andrew Brock5-Mar-11 2:42
Andrew Brock5-Mar-11 2:42 
GeneralRe: Moving GDI+ objects question Pin
csrss5-Mar-11 3:04
csrss5-Mar-11 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.