   Winsock broadcast and listen
  Hi all,I am currently developing a simple Winsock2 application that allows for servers and clients to interact with each other. As stated before it's simple and currently I am working on lan broadcasting in order for clients to ping servers available on the network. This bit has been acheived by using multicasting with a specific IP address that all the servers listen for. The problem is that, once the server has the transmission from the client I want them to send a directed packet back to the client basically with information about the server.The issue comes about when I try to make another socket on the client side that listens for the returning packet. Currently the client has one socket which is the multicast socket used for broadcasting. If I try to bind a listening socket as well, the server never receives the broadcast message and I cannot figure out why. If I dont bind the listen socket then the transmission is sent and picked up by the server fine, it's just when the listen socket is bound that the issue arises!I am a begginer to network programming and winsock so it may well be something very simple...Thanks guys.   
  There should be no problem with this.  in general, you should do something like this (there are multiple ways of doing this):Client:// Setup Broadcast Socket  BCsocket = socket(..);  .  .  .// Setup Listener socket (since you said listen, I'll assume TCP/IP)ListenSocket = socket(...);bind(ListenSocket, ...);listen(ListenSocket);while(noServerFound){  // send Broadcast message  sendto(BCsocket, ...);  // wait for reply using select on the listen socket, but set timeout for some good value, 5 second for example  SocketsReady = select(...);  if (SocketsReady > 0)  {    CommSocket = accept(ListenSocket, ...);    noServerFound = false;  }}// now CommSocket is connected to the server via TCP/IP connectionThat is the general idea.  GL   ;  Thanks for the reply. I have just about managed to figure this one out now. I am using UDP and like I said I am a newbie when it comes to network programming. It turns out that the problem was that I has binding to the same port for the multicast socket and the other socket so the interfered with each other. I am now running the multicast sockets on a different port completely to the other send/receive sockets and its going well. You live and learn...Thanks again!   ;I am currently developing a simple Winsock2 application that allows for servers and clients to interact with each other. As stated before it's simple and currently I am working on lan broadcasting in order for clients to ping servers available on the network. This bit has been acheived by using multicasting with a specific IP address that all the servers listen for. The problem is that, once the server has the transmission from the client I want them to send a directed packet back to the client basically with information about the server.Are you actually using IP multicast, or are you using UDP broadcast?For finding games on the LAN, I highly recommend UDP broadcast. I very seldom recommend IP multicast, although in some data center setups it may be useful.UDP broadcast will let you know which host sent the broadcast, too; the address will come out of recvfrom().   ;  I think its UDP broadcast, not really sure what the difference is? It's a UDP socket on both sends an the server captures datagrams for an IP in the designated multicast range.Thanks.   ;I think its UDP broadcast, not really sure what the difference is? It's a UDP socket on both sends an the server captures datagrams for an IP in the designated multicast range.If you are using IPv4:If it's broadcast, you send on the broadcast address, which is either 255.255.255.255, or it's (netaddress | (0xffffffff & netmask)) (both will work).If it's multicast, you join a multicast group, which generally involves routers collaborating, potentially across the entire globe.If you're picking a random multicast "IP address" in the reserved range for multicast addresses, and it happens to work when you send and receive packets, then you're lucky, I guess, but that's not something that you should be doing. (These are the 224.x and 232.x addresses you may see in multicast documentation)If you are using IPv6:"broadcasting" was replaced by various "multicast addresses" or the "multicast address format": http://en.wikipedia.org/wiki/IPv6_address#Multicast_address_formatIf you're using IPv6 addressing, please be more specific about what you're actually configuring.I highly recommend the Wikipedia article on multicast:http://en.wikipedia.org/wiki/IP_multicast(I would discount its claims about "scalability" because, for multicast to work on the greater internet, every router needs to talk to every other router to know what multicast groups may be currently available. Source-based multicast would solve this, perhaps, but hasn't gained any traction.)   