Commit da893bf61f1f4a379a4acf155232afdd1bae4df5
1 parent
f4c630f6
fix retrieval of remote socket information
Showing
2 changed files
with
8 additions
and
7 deletions
... | ... | @@ -43,7 +43,8 @@ TR_socketAccept(TR_TcpSocket this) |
43 | 43 | TR_Socket remote = TR_new(TR_TcpSocket, TR_socketLog(this), NULL, 0, 0); |
44 | 44 | //int flags; |
45 | 45 | |
46 | - remote->handle = accept( | |
46 | + remote->addrlen = ((TR_Socket)this)->addrlen; | |
47 | + remote->handle = accept( | |
47 | 48 | TR_socketHandle(this), |
48 | 49 | (struct sockaddr *)&(remote->addr), |
49 | 50 | &(remote->addrlen)); |
... | ... | @@ -51,14 +52,14 @@ TR_socketAccept(TR_TcpSocket this) |
51 | 52 | //flags = fcntl(remote->handle, F_GETFL, 0); |
52 | 53 | //fcntl(remote->handle, F_SETFL, flags | O_NONBLOCK); |
53 | 54 | |
54 | - remote->host = TR_strdup(inet_ntoa(remote->addr.sin_addr)); | |
55 | - remote->port = ntohs(remote->addr.sin_port); | |
56 | - remote->type = TR_socketType(this); | |
57 | - remote->flags = TR_socketFlags(this); | |
58 | - | |
59 | 55 | if (-1 == remote->handle) { |
60 | 56 | perror("accept"); |
61 | 57 | TR_delete(remote); |
58 | + } else { | |
59 | + remote->host = TR_strdup(inet_ntoa(remote->addr.sin_addr)); | |
60 | + remote->port = ntohs(remote->addr.sin_port); | |
61 | + remote->type = TR_socketType(this); | |
62 | + remote->flags = TR_socketFlags(this); | |
62 | 63 | } |
63 | 64 | |
64 | 65 | return (TR_TcpSocket)remote; | ... | ... |
Please
register
or
login
to post a comment