Thanks, I'll give it a shot.....
arishri
Posts
-
UPD large messages... -
UPD large messages...Thanks, can you give a small code example?
-
UPD large messages...Hi, Created software for electric switch (one directional) with UPD protocol. At first I created both sides with c#. Worked well but slow, had to restrain my "Transmitter" for the receiver to collect all relevant data. Now for better performance I program a native receiver. All is going well except the "recv" and the "recvfrom" methods only receive 517 bytes of the package size transmitted: (Maximal UDP)65507. How can I receive maximal upd package with a blocking socket?
-
c++ upd brodcast clientint nSize = recv(_socket, recvbuf,_nPacketSize + 1, 0);
Get no packages here....
-
c++ upd brodcast client_socket = socket(_nadressFam, SOCK_DGRAM, 17);
_socket1 = socket(_nadressFam, SOCK_DGRAM, 17);if ((\_socket == INVALID\_SOCKET) || (\_socket1 == INVALID\_SOCKET)) { fprintf(stderr, "Could not create socket.\\n"); WSACleanup(); exit(0); }
-
how to get ip address of a hostchar cNamearr[255];
gethostname(cNamearr, 255);
hostent* hp = gethostbyname(cNamearr);\_sockaddr.sin\_addr.s\_addr = \_nAdapterIp;//inet\_addr((const char\*)\_ucIpCharArr); \_sockaddr.sin\_addr.S\_un.S\_un\_b.s\_b1 = hp->h\_addr\_list\[0\]\[0\]; \_sockaddr.sin\_addr.S\_un.S\_un\_b.s\_b2 = hp->h\_addr\_list\[0\]\[1\]; \_sockaddr.sin\_addr.S\_un.S\_un\_b.s\_b3 = hp->h\_addr\_list\[0\]\[2\]; \_sockaddr.sin\_addr.S\_un.S\_un\_b.s\_b4 = hp->h\_addr\_list\[0\]\[3\];
-
c++ upd brodcast clientsorry abut that, I shorten it so the code will be clear.... The actual code has the tests:
if (WSAStartup(0x0101, &_wsaData) != 0)
{
fprintf(stderr, "Could not open Windows connection.\n");
exit(0);
}char broadcast= (char)1;
if (setsockopt(\_socket, SOL\_SOCKET, SO\_BROADCAST, &broadcast ,sizeof(broadcast)) != 0) { fprintf(stderr, "Could not set socket options.\\n"); WSACleanup(); exit(0); }
etc....
-
c++ upd brodcast clienthi I'm programming a c++ client to receive packets from a server (UDP broadcast). This is a hardware switch (One direction only) system so I have no information regarding the senders address or any other info. It all compiles and binds OK but no packets received.
WSAStartup(0x0101, &_wsaData);
memset((char *)&_sockaddr, 0, sizeof(_sockaddr));
_sockaddr.sin_addr.s_addr = _nAdapterIp;
_sockaddr.sin_family = _nadressFam;
_sockaddr.sin_port = _usPort; //Gave it a try with (0) - also not working
_socket = socket(_nadressFam, SOCK_DGRAM, 0); //Gave it a try with (17) - UDP for the 3 rd parameter - not working
char broadcast='1';
setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, &broadcast ,sizeof(broadcast));
bind(_socket, (sockaddr*) & _sockaddr, sizeof (_sockaddr));
char* recvbuf = new char[_nPacketSize + 1];
int nSize = recv(_socket, recvbuf, _nPacketSize + 1, 0);Any ideas? Thanks,