开发者

Listening UDP and monitoring

开发者 https://www.devze.com 2023-02-16 11:59 出处:网络
I have already created a UDP socket (UDP has been bound) and now i wanted the server to listen and if any client tries to connect, the listening UDP will then accept and pass the socket to a n开发者_开

I have already created a UDP socket (UDP has been bound) and now i wanted the server to listen and if any client tries to connect, the listening UDP will then accept and pass the socket to a n开发者_开发问答ew thread to perform recvfrom and sento operation.

So how am I going to do that? How the client tells the server that he wanted to connect? May I use FD_CONNECT and FD_ACCEPT in UDP?

Thank you.


UDP is a connectionless protocol. You don't need to connect an udp socket. Pay attention that use a connect on an UDP socket may have a different semantic respect what you are expecting: on linux for example a connect invoked on a UDP socket , "bind" that socket to a specific IP address, but this is only a local binding, nothing happens over the network.

0

精彩评论

暂无评论...
验证码 换一张
取 消