Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Wickeeed

UDP Client's

This topic is 5214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi to all, i was trying to run a UDP Server, and i found out what there is no accept function inside ! and i wonder how do i have to listen clients if i dont even know thair sockets? mfg wicked

Share this post


Link to post
Share on other sites
Advertisement
With UDP you usually don't have a single port per client, but rather one port for everyone. Like the op stated, you can get the address of the sender with recvfrom(), and you can send messages directed at a specific address from the same socket.



Looking for a serious game project?
www.xgameproject.com

[edited by - Max_Payne on April 21, 2004 7:55:54 PM]

Share this post


Link to post
Share on other sites
With UDP, you open up one port and let other people send data to you via that port. Clients connecting must know your ip and port to connect to. The same way you would connect to a Quake 2 server. Depending on whether or not you have blocking enabled, you would simply poll that port for incoming. If data is waiting to be read from that port, you will get it and the address of the client who sent it. Everything from that point is application/protocol specific.

Intro Engine

Share this post


Link to post
Share on other sites
my problem is that if i have 15 fast clients and 15 slow, then it may only recev messages from faster clients even if i recv messages 100 times every frame. i just dont know how to recv messages from all clients without waiting :|

edit: can this be that recvfrom() is blocking like accept `? ???

[edited by - Wickeeed on April 22, 2004 6:03:25 AM]

Share this post


Link to post
Share on other sites
By default (in winsock) sockets are created as blocking.

For non-blocking action either use ioctlsocket() to set the socket to non-blocking mode or better still use the WSAAsyncSelect/WSAEventSelect functions to activate asynchronous message/event notifications.


[edited by - arm on April 22, 2004 6:31:24 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by arm
By default (in winsock) sockets are created as blocking.

For non-blocking action either use ioctlsocket() to set the socket to non-blocking mode or better still use the WSAAsyncSelect/WSAEventSelect functions to activate asynchronous message/event notifications.




how to use WSAAsyncSelect/WSAEventSelect ??? is that the same thing like select in TCP ?? can i use them if i only know client's ip's and nothin else.

is ioctlsocket() the best thing for UDP recvfrom()?
edit: or shul i make a thread for this?




[edited by - Wickeeed on April 22, 2004 6:44:31 AM]

Share this post


Link to post
Share on other sites
WSAAsyncSelect() tells winsock to message a window whenever a network event occurs. You can select the events that cause notifications.

WSAEventSelect() tells winsock to set an Event object whenever a network event occurs. Again, you can select the events that cause notifications.

ioctlcsocket() simply makes calls like recvfrom non-blocking so that if you call them and there is no data available, they will just return an error - you have to keep polling them until data is available.

Look at the documentation to learn more about the above functions. I cant tell you which one will fit best into your application.

Share this post


Link to post
Share on other sites
If i get it all right then that means that if i wuld use two TCP servers, one on blocking socket and one on non-blocking socket.. then the one that runs on non-b TCP will be like UDP and have the same speed ??? or it will be still slower ?

arm: i have searched a lot on google and still cant find a good tutorial or fag about these functions..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!