serverSocket handling several easyTcpSockets

I’ve set a serverSocket object to handle all of my easyTcpSocket class sessions. I’ve added a custom property to the easyTcpSocket class called ‘sessionId’. This property is populated with a unique ID that I assign when the connection is established. Is there any way to iterate through this in the main thread and compare sessionIds… like if I wanted to send one socket connection a particular message? I tried variations of the severSocket.activeConnections(); however, it expected a tcpSocket class and not an easyTcpSocket. What I want is probably fairly simple to do, but I’m making it complicated… like always. Any suggestions would be appreciated.

FYI… I don’t have to use the sessionId property. If I’m limited to just a handle of the object or something else, that’s fine. I just need to be able to process messages outbound to a specific socket connection.

What about a global array where you add your session infos on connection and remove when dropping?

Rick, that’s kind of what I just did. I added a global dictionary which added a key based on the unique ID, and set the value to the instance of the easyTcpSocket itself. Worked like a charm… thanks!

You simply cast each socket to your custom type.

dim sock() as TCPSocket = server.ActiveConnections
for i = 0 to Ubound(sock)
   if mySocketClass(sock(i)).IDNumber = theNumber then
   ...

[quote=92718:@Tim Hare]for i = 0 to Ubound(sock)
if mySocketClass(sock(i)).IDNumber = theNumber then[/quote]

Being t the time to access the info, and i the highest index of an expanding array; in a sequential search, if i -> ? then t -> ?

Using dictionaries with keys we have lower t’s for large i’s. I still prefer Eric’s way to find a specific session.

Just tried it in a small project. No problems.

The kind of socket should have no bearing, since you’re declaring sock() as TCPSocket.