• Welcome to Valhalla Legends Archive.
 

Multiple People 1 winsock

Started by Hdx, December 13, 2004, 10:02 PM

Previous topic - Next topic

Hdx

I was wondering, If it was possible for you to have multiple people connected to you on a single port.
Let me explain, I'm working on a small chat client. Not a battle.net chat client. A 'instant messanger'.
As I ahve it right now I have 1 socket listing on port 1990. Every time it recives a connection it creats another winsock, on a diffrent port. incramenting form 1990. (1st one is 1991, 2nd 1992, 3rd 1993, etc...) But I really dont liek this idea because it would require people behind routers to forword alot of ports. And if there like me, thats a bitch -.-

What i was wondering is if i could jusut have the 1 winsock. Listin for all connections, and incoming data, and jsut spit it out to the diffrent chat windows. Also, how would I send text to the correct person?
Any Ideas, suggestions? Need more explanation?
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

UserLoser.

You just have one socket which is the listener, and you create other sockets when there are incoming connection requests.  When there's an incoming connection request, load a new winsock, and accept the connection (see: requestId parameter of ConnectionRequest event) on the newly loaded socket.  But make sure to re-listen on your original listening socket.

Hdx

thank you UL for that speedy repley. Also that is egzactly what i was needing. God knows why i didnt think of it... O well thank you alot, works liek a charm.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

R.a.B.B.i.T

I actually prefer using 1 set of winsocks.  I create a socket, bind it, and make it listen.  It accepts the first connection and creates a new socket (which does the same thing).  If the the socket fails for some reason, its index is put into a pool of free sockets that can now be re-used or destroyed.

Networks

I also have a question pretaining somewhat to this. How could you set up a 1 on 1 IP chat network if someone is on a router or etc. How can you bypass it?

UserLoser.

Quote from: Networks on December 15, 2004, 03:51 PM
I also have a question pretaining somewhat to this. How could you set up a 1 on 1 IP chat network if someone is on a router or etc. How can you bypass it?

Depends on who is hosting it.  If the person with the router is, then obviously allow incoming connections on that port.  Otherwise, there shouldn't be any issues (assuming all firewalls don't exist/disabled/allow that port)