0

I'm doing a communication between a sever (by running the linux command netcat -ul 1234) and a c++ client program. The communication works fine when I send data without closing the socket, but if I close the socket and re-open it, my messages wont be received on the netcat terminal. Here is my c++ code :

struct sockaddr_in m_addr;
bzero(&m_addr,sizeof(m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_addr.s_addr = inet_addr(my_ip);
m_addr.sin_port = htons(my_port);

int m_socket = socket(AF_INET,SOCK_DGRAM,0);

sendto(m_socket,m_data,m_length,0,(struct sockaddr*)&m_addr,sizeof(m_addr))

close(m_socket);

When I execute this code for the first time the netcat receives the data without any problem, but when I re-execute the code again the server wont receive any thing.

youssef1700
  • 109
  • 11

0 Answers0