Cant connect port 9150 c++ -
i trying connect port 9150 on localhost ( tor ) code:
word wversionrequested = makeword(2,0); wsadata wsadata; if(wsastartup(wversionrequested,&wsadata) != 0) { return 1; } int fd = socket(af_inet, sock_stream, 0); if(fd < 0) { printf("error 0"); } struct sockaddr_in saddr; saddr.sin_port = htons(9150); saddr.sin_family = af_inet; saddr.sin_addr.s_addr = inet_addr("127.0.0.1"); connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if(fd > 0) { printf("error 1"); }
and failing "error 1". tor/vidalia runing on port , ok, erro must in code. me please.
minor things here:
#include <stdio.h> /* perror() */ word wversionrequested = makeword(2,0); wsadata wsadata; if(wsastartup(wversionrequested,&wsadata) != 0) { return 1; } int fd = socket(af_inet, sock_stream, 0); int rv = 0; if(fd < 0) { perror("socket"); exit(fd); /* or return */ } struct sockaddr_in saddr; saddr.sin_port = htons(9150); saddr.sin_family = af_inet; saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
your core problem in code below
rv = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if(rv < 0) { perror("connect"); exit(rv); /* or return */ }
Comments
Post a Comment