473,513 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is socket.shutdown(1) useless

Issues of socket programming can be wierd, so I'm looking for some
comments.

In my python books I find exclusive use of socket.close(). From my
other readings, I know about a "partial close operation". So, I figured
it would be useful to post some code about how socket.close() has an
implicit send in it and you can actually gain some clarity by being
more explicit with the partial close which means splitting
socket.close() up into socket.shutdown(1) and socket.close().

And got a response in essence saying, why bother, socket.shutdown,
isn't useful.

Here is my thinking:

With a standard socket.close(), the client closes the socket
immediately after the implicit send. This means the client assumes it
was ok to actually close the socket, independant of how the server
reacts to that last bit of data. To me that is an assumption you may
not always want to make.

If, instead, the client does a socket.shutdown(1) to say it is done
sending, it can still recv and wait for the server to respond with
either:
1)yep, I agree you finished sending
or
2)I know you are done,and I got your data, but I do not think you are
done

To me these seem like a very useful distinction, since now if the
client cares, it can find out if it's final communication did matter.
It helps avoid what I call the princess bride phenomenon of #2:

"You keep using that word. I do not think it means what you think it
means."

So, is this whole business with socket.shutdown mostly useless? So
useless that I cannot find any mention of it in 2nd edition,
Programming Python.

john

Jul 18 '05 #1
1 6318
py****@gmail.com wrote:
In my python books I find exclusive use of socket.close(). From my
other readings, I know about a "partial close operation". So, I figured
it would be useful to post some code about how socket.close() has an
implicit send in it and you can actually gain some clarity by being
more explicit with the partial close which means splitting
socket.close() up into socket.shutdown(1) and socket.close().

And got a response in essence saying, why bother, socket.shutdown,
isn't useful.


I had to use socket.shutdown once because the socket architecture we had
relied on sending a piece of data, waiting for it to be processed, and
then receiving a result back. The server on the other end of the socket
wouldn't process anything until it was sure that all data had been sent.
So our code basically looked like:

s = socket.socket(...)
s.connect(...)
s.send(...)
s.shutdown(1)
data = s.makefile().read()
s.close()

STeVe
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
121507
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
4
18087
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
2
702
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
11
7676
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
2
13124
by: yvan | last post by:
Hi, Here is my client/server scenario: Step1: Client connects to server and sends data sucessfully (using Socket.Send()). Step2: Server gracefully exists (calls Socket.Shutdown() and...
2
4219
by: mumebuhi | last post by:
I am having problem to kill the following script completely. The script basically does the following. The main thread creates a new thread, which does a completely useless thing, and then starts...
0
1813
by: mumebuhi | last post by:
I removed my previous post about this topic because I apparently have pasted the wrong code. Sorry for the confusion and thanks for being patient. I am having problem to kill the following...
11
8580
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
0
3102
by: jkhan | last post by:
Hi! I have problem which I shown in title and below as well. I have a Form name as Cancelation. The clientThread2() method is called on Form Load if I Close the Form and want to reload then the...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.