I have a server.java and a client.python file. When I try the following, however, I get a "[Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions" error. Is there a way around this? Why is this happening?
client.py
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sockRecv = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((socket.gethostname(),4000))
sockRecv.bind((socket.gethostname(),4000 + 1))
server.java
recvSocket = new DatagramSocket(4000);
sendSocket = new DatagramSocket(4000 + 1);
What your code is doing doesn't make sense, to me.
The IP address + port represents an end-point for datagram communication. If two applications were able to bind to the same end-point, which of them would receive the packets sent to the end-point? One of them? Both of them?
UDP is not a multi-cast protocol .... unless you bind to a multicast IP address.
Based on hints in your code (names of variables) I think you are trying to set up message passing between two applications on the same host. If so you should do this:
There is no need for applications A and B bind to the same end-point; ie the same port ... to do what I think you are trying to do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.