desktop2
asked on
bind() error 10022
s=WSASocket(AF_INET, SOCK_RAW, IPPROTO_TCP, NULL, 0,0);
memset((char *) &sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family=AF_INE T;
sockaddr.sin_port=htons(22 22);
sockaddr.sin_addr.s_addr=h tonl(INADD R_ANY);
bind(s,(LPSOCKADDR)&sockad dr, sizeof(sockaddr)); // return error 10022 :-(
If I don't bind() socket how can I receive packets? On which port ?
memset((char *) &sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family=AF_INE
sockaddr.sin_port=htons(22
sockaddr.sin_addr.s_addr=h
bind(s,(LPSOCKADDR)&sockad
If I don't bind() socket how can I receive packets? On which port ?
ASKER
Than it will be regular TCP connection...
What I want to do is to receive and handle all packets like SYN, ACK, RST.
It looks like I need to use RAW socket for this task.
What I want to do is to receive and handle all packets like SYN, ACK, RST.
It looks like I need to use RAW socket for this task.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
10022 is defined as "WSAEINVAL", which usually means "An invalid argument was supplied.", but if you read the documentation for bind(), it says that it will return that value when "The socket is already bound to an address."
Is there more to your code than just that?
I think the problem may be in the first line, because I reviewed my socket library, and it seems to do what you're doing. The main difference is that I am SOCK_STREAM instead of SOCK_RAW, 0 for the protocol type. So try changing it to this line:
s=WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0,0);
Hope that Helps,
Dex*