Click here to Skip to main content
15,908,634 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A very basic socket question Pin
Joaquín M López Muñoz17-Jul-02 3:29
Joaquín M López Muñoz17-Jul-02 3:29 
GeneralRe: A very basic socket question Pin
includeh1017-Jul-02 3:39
includeh1017-Jul-02 3:39 
GeneralRe: A very basic socket question Pin
Dave_17-Jul-02 3:51
Dave_17-Jul-02 3:51 
GeneralRe: A very basic socket question Pin
includeh1017-Jul-02 4:05
includeh1017-Jul-02 4:05 
GeneralRe: A very basic socket question Pin
Dave_17-Jul-02 4:11
Dave_17-Jul-02 4:11 
GeneralRe: A very basic socket question Pin
Bubba214617-Jul-02 7:20
Bubba214617-Jul-02 7:20 
GeneralRe: A very basic socket question Pin
Dave_17-Jul-02 7:37
Dave_17-Jul-02 7:37 
GeneralRe: A very basic socket question Pin
Bubba214617-Jul-02 7:58
Bubba214617-Jul-02 7:58 
Dave_ wrote:
The application is not actually a server. There are two threads, one for sending, and one for receiving.

This is fine and makes sense.

Dave_ wrote:
When the PC sends a message, it will send using a constant source port number of 1594.

This does not. The source port number applies when you are *sending* a message and should be determined by the operating system when you create the socket. This should not be a constant. The reason is you have no way of knowing (realistically) what ports are being used, so the OS takes care of it for you.

To help clarify:
1. Computer A wants to send a message to computer B
2. Computer B binds to a port (say 2000)
3. Computer A opens a socket connection to B and the OS assigns it a port of 47826 (essentially random from A's point of view) to use
4. Computer A sends a message to port 2000 on B

Now, from A's point of view, 2000 is the *destination* port, and 47826 is the *source* port.

Dave_ wrote:
I don't understand how I could possibly be recieving messages if when I pass in IN_ADDRANY, and 0 for the port number, and that results in a port number 1679 (for example) after the bind, since most messages (if not all) are coming in on port 1594?

See, if your messages are coming in on port 1594 then your server must be listening on the same port to receive them. That's why, for the receiving computer, it doesn't make sense to dynamically let the OS determine the port to bind to. You'll want to explicitly bind to port 1594, not 0.

Forgive me if I'm missing something, but I hope that clears up what I'm trying to say.
GeneralRe: A very basic socket question Pin
Dave_17-Jul-02 8:11
Dave_17-Jul-02 8:11 
GeneralRe: A very basic socket question Pin
Bubba214617-Jul-02 8:27
Bubba214617-Jul-02 8:27 
GeneralRe: A very basic socket question Pin
Dave_17-Jul-02 8:29
Dave_17-Jul-02 8:29 
GeneralPassing a control id Pin
moobob17-Jul-02 3:18
moobob17-Jul-02 3:18 
GeneralRe: Passing a control id Pin
Joaquín M López Muñoz17-Jul-02 3:21
Joaquín M López Muñoz17-Jul-02 3:21 
GeneralRe: Passing a control id Pin
moobob17-Jul-02 3:31
moobob17-Jul-02 3:31 
Questiondbdao.h : what is the matter now? Pin
includeh1017-Jul-02 3:13
includeh1017-Jul-02 3:13 
AnswerRe: dbdao.h : what is the matter now? Pin
Michael P Butler17-Jul-02 3:36
Michael P Butler17-Jul-02 3:36 
GeneralRe: dbdao.h : what is the matter now? Pin
includeh1017-Jul-02 3:46
includeh1017-Jul-02 3:46 
GeneralMemory Managment Pin
c_sisbit17-Jul-02 3:12
c_sisbit17-Jul-02 3:12 
GeneralRe: Memory Managment Pin
Joaquín M López Muñoz17-Jul-02 3:18
Joaquín M López Muñoz17-Jul-02 3:18 
GeneralRe: Memory Managment Pin
includeh1017-Jul-02 3:21
includeh1017-Jul-02 3:21 
GeneralRe: Memory Managment Pin
c_sisbit17-Jul-02 3:41
c_sisbit17-Jul-02 3:41 
GeneralRe: Memory Managment Pin
Joaquín M López Muñoz17-Jul-02 3:46
Joaquín M López Muñoz17-Jul-02 3:46 
GeneralRe: Memory Managment Pin
c_sisbit17-Jul-02 3:47
c_sisbit17-Jul-02 3:47 
GeneralRe: Memory Managment Pin
Joaquín M López Muñoz17-Jul-02 3:50
Joaquín M López Muñoz17-Jul-02 3:50 
GeneralRe: Memory Managment Pin
c_sisbit17-Jul-02 3:59
c_sisbit17-Jul-02 3:59 

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.