c++ udp 10038 socket error on sendto() -


i'm getting 10038 socket error on sendto() call. causing this? i'm not getting errors upon socket creation or binding. here's how set socket:

client client; client.client_socket = client.open_port(peer_port2); //5001 client.prompt("enter router hostname: ",router); client.sa_out = client.prepare_peer_connection(router, router_port2); //7001 

open_port

socket client::open_port(int port) {     socket sock;      sockaddr_in sa;     hostent *hp;      char hostname[11];       gethostname(hostname,11);      if((hp=gethostbyname(hostname)) == null)          throw "could not determine host address supplied name";      sa.sin_family = af_inet;     sa.sin_port = htons(port);     sa.sin_addr.s_addr = htonl(inaddr_any);      if((sock = socket(af_inet,sock_dgram,0))==invalid_socket)      throw "generating new local socket failed";      if (bind(sock,(lpsockaddr)&sa,sizeof(sa)) == socket_error)      throw "could not bind socket supplied port";      return sock; } 

prepare_peer_connection

sockaddr_in client::prepare_peer_connection(char* hostname, int port) {     sockaddr_in sa;     hostent *hp;      if((hp = gethostbyname(hostname)) == null)           throw "could not determine host address supplied name";      memcpy(&sa_out.sin_addr, hp->h_addr, hp->h_length);     sa.sin_family = hp->h_addrtype;     sa.sin_port = htons(port);      return sa; } 

the function sendto() call causing 10038

int client::send_packet(socket sock, sockaddr_in sa, char* buffer, int size, int pid) {     int ibytessent = 0;     int packet_size = size + sizeof(int);     int = sizeof(sa);      char packet[132]; //128 + 4      make_packet(packet, buffer, size, pid);      if ((ibytessent = sendto(sock,packet,packet_size,0,(sockaddr*)&sa, from)) == socket_error)     {         throw "send failed";     }     else     {         memset(buffer,0,size);         return ibytessent - sizeof(int);      } } 


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -