Solved the "cannot accept connection" problem.
This commit is contained in:
parent
2b8101ddf6
commit
e694e5a5b3
1 changed files with 6 additions and 5 deletions
3
ddcd.cpp
3
ddcd.cpp
|
@ -100,6 +100,7 @@ int main(int argc, char* argv[])
|
||||||
memset(&addr_host,'0',sizeof(addr_host));
|
memset(&addr_host,'0',sizeof(addr_host));
|
||||||
addr_host.sin_family=AF_INET;
|
addr_host.sin_family=AF_INET;
|
||||||
addr_host.sin_port=htons(host_port);
|
addr_host.sin_port=htons(host_port);
|
||||||
|
addr_host.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
if( (addr_host.sin_addr.s_addr=inet_addr(host_address)) == INADDR_NONE )
|
if( (addr_host.sin_addr.s_addr=inet_addr(host_address)) == INADDR_NONE )
|
||||||
{ fprintf(stderr, MSG_START "invalid host address.\n"); exit(1); }
|
{ fprintf(stderr, MSG_START "invalid host address.\n"); exit(1); }
|
||||||
|
@ -113,7 +114,7 @@ int main(int argc, char* argv[])
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr_cli;
|
struct sockaddr_in addr_cli;
|
||||||
socklen_t addr_cli_len;
|
socklen_t addr_cli_len = sizeof(addr_cli);
|
||||||
int new_socket;
|
int new_socket;
|
||||||
|
|
||||||
if( (new_socket = accept(listen_socket, (struct sockaddr*)&addr_cli, &addr_cli_len)) == -1)
|
if( (new_socket = accept(listen_socket, (struct sockaddr*)&addr_cli, &addr_cli_len)) == -1)
|
||||||
|
|
Loading…
Reference in a new issue