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 1 6342 py****@gmail.co m 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().re ad()
s.close()
STeVe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 alpha)
so I deinstall mysql5-server and mysql5-client
And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by
ports
but now , mysql is not workable
|
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 as I find appropriate.
I am using the socket asynchronously by calling the BeingSend and
BeginReceive calls. I would like to be able to call shutdown and close
asynchronously if possible.
|
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
more data to expect). Sometimes, Socket.Available returns 0 but the other
end of the connection did not close it !
2) This class will be used by many other classes so I have to use the
|
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 the app, even the first time. The application will
be required to be sending out repeated emails, about one every second or
two.
Must this be done asynchronously? Thank you. -Greg
I get the generic error messages;
|
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
Socket.Close()). I see the server connection status go from ESTABLISHED to
FIN_WAIT2, the client connection go from ESTABLISHED to WAIT_CLOSE.
Step3: client.Send() succeeds and return the number of bytes sent (over the
closed connection!)
| |
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 excepting for a
connection via socket.
# start
import pickle
import signal
import simplejson
import socket
|
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 script completely. The script
basically does the following. The main thread creates a new thread,
which does a completely useless thing, and then starts excepting for a
connection via socket.
# start
|
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 mechanisms.
I use a non-blocking approach for this, using the call to 'poll' to
support the async mechanism - rather than the 'begin' and 'end'
functions. I already found that connecting doesn't set the
"isconnected" variable correctly...
|
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 above error is generated as I tried to close, shutdown etc for closing the socket or thread but useless. Any one have idea about it.
The above error is generated when it reached to this line ==> sender = new IPEndPoint(IPAddress.Any, 0); as I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |