Leo Chai
|
A question about socket on QNX6.3.2
|
Leo Chai
05/25/2011 2:29 AM
post86106
|
A question about socket on QNX6.3.2
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main()
{
int sock;
struct sockaddr_in addrSrv;
sock = socket(PF_INET, SOCK_STREAM, 0);
memset(&addrSrv, 0, sizeof(struct sockaddr));
addrSrv.sin_addr.s_addr = inet_addr("192.168.2.3");
addrSrv.sin_family = PF_INET;
addrSrv.sin_port = htons(6000);
if (bind(sock, (struct sockaddr*)&addrSrv, sizeof(struct sockaddr)) != 0)
{
printf("bind failed.\n");
}else{
printf("bind succeed\n");
}
return 0;
}
As shown above, I just want to test the bind function on QNX 6.3.2.
"qcc sock.c -l socket -o sock" to compile the code in QNX without IDE. Whenever run the program, the result is aways "
bind failed."(he IP addr is correct). However, it is "bind succeed" with the same code on QNX 6.5.0
Can amyone tell me what's wrong with the code or the OS.
|
|
|