Understanding how the ServerSocket works?

Hi all,

I have a quick question for you all about ServerSockets, as I am trying to get an improved understanding of how this feature works. :slight_smile:

I am correct in my understanding that when a client makes a connection to a ServerSocket (for example on port 7500), that the ServerSocket will connect them to TCPSocket connection? Is this correct?

Does the ServerSocket then configure the TCPSocket’s connection, so that it knows which IP address to reply to, what port to communicate on, etc?

From what I am seeing, it looks like a connection comes into the ServerSocket, the AddSocket creates a pool of available connections, and then … I guess I am trying to figure out what’s next and how the actual connection is made. :wink:

Thank you!

Byron

Yes, it’s remarkably simple. You get a connected event - the whole process is atomatic.

Here’s a small project which implements all that for POP3 and SMTP.

iServer B30 (R).zip (691.1 KB)

1 Like

Hi Tim,

Thank you very much for letting me know – especially for the example! Wow, much appreciated. :smiley:

Byron

The ServerSocket sits and waits for incoming connections. When a connection is attempted, it fires the AddSocket event. Your code must then respond to the event by supplying it a TCPSocket (or subclass). The ServerSocket then attaches the socket to the incoming connection and it proceeds per normal socket behavior.

1 Like