× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi!

i have a problem with my rpg server program.

i am followig the code from Scott Klement to wite a simple server program.

i create a socket, bind it, listen and accept a connection. the i send a
small string and receive a small string.

after that i close the accepted socket and the original server socket used
for bind.

But sometimes the connection stay open and the close of the socket is not
successfull. i cannot restart the serer because the socket is already
bound.

when i do netstat *cnn i see the connection is in state time_wait and the
listening socket is not closed.

both close calls return withaout an error so why does the os not close the
sockets?

Grettings,
Fanz

Here is the Code:

message = 'TEST';
address = *allx'00';
address.sin_family = AF_INET;
address.sin_port = 9001;
address.sin_addr.s_addr = INADDR_ANY;

connection = socket(AF_INET:SOCK_STREAM:IPPROTO_TCP);
if bind(connection:%addr(address):%size(address) ) = -1;
rc = close(connection);
return;
endif;

if listen(connection:1 ) < 0;
rc = close(connection);
return;
endif;

newsock = accept(connection:p_address2:len);
len = send(newsock:%addr(message:*data):%size(message):0);
len = recv(newsock:%addr(ret):%size(ret):0);
rc = close(newsock);
rc1 = close(connection);
printf('message: %s %s %s <<%s>>' + x'25' : %char(rc) : %char(rc1):
%char(len): ret);


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.