return -1;\r
}\r
\r
+ printf("Connection opened\n");\r
+ \r
writef(srv.FD, "USER %s %s %s : %s\n", gsUsername, gsHostname, gsRemoteAddress, gsRealName);\r
writef(srv.FD, "NICK %s", gsNickname);\r
\r
*/\r
int OpenTCP(const char *AddressString, short PortNumber)\r
{\r
- int fd, addrType, iface;\r
+ int fd, addrType;\r
+ char *iface;\r
char addrBuffer[8];\r
\r
// Parse IP Address\r
\r
// Finds the interface for the destination address\r
iface = Net_GetInterface(addrType, addrBuffer);\r
- if( iface == -1 ) {\r
+ if( iface == NULL ) {\r
fprintf(stderr, "Unable to find a route to '%s'\n", AddressString);\r
return -1;\r
}\r
\r
+ printf("iface = '%s'\n", iface);\r
+ \r
// Open client socket\r
// TODO: Move this out to libnet?\r
{\r
- int len = snprintf(NULL, 100, "/Devices/ip/%i/tcpc", iface);\r
+ int len = snprintf(NULL, 100, "/Devices/ip/%s/tcpc", iface);\r
char path[len+1];\r
- snprintf(path, 100, "/Devices/ip/%i/tcpc", iface);\r
+ snprintf(path, 100, "/Devices/ip/%s/tcpc", iface);\r
fd = open(path, OPENFLAG_READ|OPENFLAG_WRITE);\r
}\r
\r
+ free(iface);\r
+ \r
if( fd == -1 ) {\r
+ fprintf(stderr, "Unable to open TCP Client for reading\n");\r
return -1;\r
}\r
-\r
+ \r
// Set remote port and address\r
+ printf("Setting port and remote address");\r
ioctl(fd, 5, &PortNumber);\r
ioctl(fd, 6, addrBuffer);\r
\r
// Connect\r
+ printf("Initiating connection");\r
if( ioctl(fd, 7, NULL) == 0 ) {\r
// Shouldn't happen :(\r
+ fprintf(stderr, "Unable to start connection\n");\r
return -1;\r
}\r
\r