Solved

comunication question

Posted on 2001-06-10
9
880 Views
Last Modified: 2008-02-01
I have a server sending data on request to several hundreds of clients.

server and client are written in c++, communication is a class I've written and uses non-blocking sockets with winsock 2.

my question is:
What is the effect on my users if I use SO_LINGER with a timeout of 0, instead of SO_DONTLINGER ?

how will it affect reconnection to the server ?

0
Comment
Question by:guyss
9 Comments
 

Expert Comment

by:RanganathanVenkatakrishnan
ID: 6176025
LINGER structure is used by an application to set the linger socket option and specify the length of time to wait for unsent data before a socket is closed.

The LINGER stucture as U know has 2 members.
Following steps should be performed to enable or disable linger option.

A) To enable SO_LINGER, the application should set l_onoff to a nonzero value, set l_linger to zero or the desired timeout (in seconds), and call setsockopt.

B) To enable SO_DONTLINGER (that is, disable SO_LINGER) l_onoff should be set to zero and setsockopt should be called

Hence, giving value of timeout of 0 is not equivalent to
SO_DONTLINGER .

Note:
Enabling SO_LINGER with a nonzero timeout on a nonblocking socket is not good.
0
 
LVL 1

Author Comment

by:guyss
ID: 6176046
I wanted to know what the effect would be, I know how to do it...
0
 
LVL 5

Accepted Solution

by:
djbusychild earned 100 total points
ID: 6176093
if you do SO_LINGER with 0 time out it'll forcefully shut the connection off meaning it'll just terminate connection without giving the queued up packets a chance to be sent out. If you set SO_DONTLINGER then although it'll return immediately without blocking, te packets will get a chacne to be sent out
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 1

Author Comment

by:guyss
ID: 6176126
I use closesocket when I detect a disctonnection from the server, I use my own keep-alive/tiemout mechanism.

will the other side of the socket get any different response than when using SO_DONTLINGER ?

will I have any problems when the user attempts to reconnect, (i.e - open another socket for the same port and ip address) ?

0
 
LVL 5

Expert Comment

by:djbusychild
ID: 6177948
well, when you have SO_DONTLINGER you won't be able to bind again to the same port/ip until the timer on the underlying layer has expired.
0
 
LVL 1

Author Comment

by:guyss
ID: 6179997
how would this be detected ? a failure in opening the socket again ? I never saw this happen.
0
 
LVL 5

Expert Comment

by:djbusychild
ID: 6182106
I've not tried this under Windows. When I was doing development under Sun, I experience that bind will fail if I try to bind immediately after closing.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6814513
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "dbusychild" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

Please do not accept this comment as an answer!
======
Werner
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6833231
Per recommendation comment force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question