# Understanding how the ServerSocket works?

**URL:** <https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408>\
**Category:** Getting Started\
**Created:** [February 26, 2025, 7:36pm UTC](https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408 "2025-02-26T19:36:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Byron\_Minick](https://forum.xojo.com/user_avatar/forum.xojo.com/byron_minick/32/869_2.png) [@Byron\_Minick](https://forum.xojo.com/u/Byron_Minick)\
**Post date:** [February 26, 2025, 7:36pm UTC](https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408/1 "2025-02-26T19:36:48Z")

</div>

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. 🙂

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. 😉

Thank you!

Byron

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [February 26, 2025, 7:40pm UTC](https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408/2 "2025-02-26T19:40:12Z")

</div>

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](https://forum.xojo.com/uploads/short-url/giA2TUzJdwQWe4qbm0qfNADIiUP.zip) (691.1 KB)

---

<div class="post-metadata">

**Author:** ![Byron\_Minick](https://forum.xojo.com/user_avatar/forum.xojo.com/byron_minick/32/869_2.png) [@Byron\_Minick](https://forum.xojo.com/u/Byron_Minick)\
**Post date:** [February 26, 2025, 8:34pm UTC](https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408/3 "2025-02-26T20:34:28Z")

</div>

Hi Tim,

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

Byron

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [February 26, 2025, 8:34pm UTC](https://forum.xojo.com/t/understanding-how-the-serversocket-works/84408/4 "2025-02-26T20:34:32Z")

</div>

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.
