Does a streaming socket send / receive broadcast messages?

I looked at the python socket docs and google docs for two days, but I did not find an answer. Yes, I am new to network programming :)

I would like to implement some network communication system with a specific function for our needs. I am at the very beginning. I was able to implement a client-server model where the client connects to the server (socket.SOCK_STREAM), and they can modify messages. I want to take a step forward. I want the client to detect the broadcast LAN as many other clients are available. I failed. Is it possible that a socket of type socket.SOCK_STREAM cannot be used for this task? If so, what are my options? using udp packages? How should I listen to brodcast messages / packages?

+6
python
source share
1 answer

The broadcast is determined by the destination address.

For example, if your own ip is 192.168.1.2, the broadcast address will be 192.168.1.255 (in most cases)

It is not directly related to python and probably will not be in its documentation. You are looking for network β€œgeneral” knowledge at a level far superior to socket programming.

* EDIT

Yes, you are right, you cannot use SOCK_STREAM. SOCK_STREAM defines a TCP connection. You must use UDP to translate using socket.SOCK_DGRAM

+4
source share

All Articles