Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - A question about socket on QNX6.3.2: (1 Item)
   
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.