Hi
I'm working with sockets and I'm curious about the timout when trying to
connect to a server on a specific port.
My code looks like this:
Socket client = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
int port = Int32.Parse( TextBox_Port.Text );
string ip = TextBox_IP.Text;
ipAdd = IPAddress.Parse( ip );
remoteEP = new IPEndPoint ( ipAdd, port );
client.Connect (remoteEP);
What I can't get a grip on is the long timout period if the server does not
respond.
I've tried adding:
client.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 500);
client.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 500);
but this does not help...
Is there a way of controling the timeout on connect?
/Johan 2 6882
Did you try setting ReceiveTimeout also?
David.
"Johan" wrote: Hi
I'm working with sockets and I'm curious about the timout when trying to connect to a server on a specific port.
My code looks like this:
Socket client = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp); int port = Int32.Parse( TextBox_Port.Text ); string ip = TextBox_IP.Text; ipAdd = IPAddress.Parse( ip ); remoteEP = new IPEndPoint ( ipAdd, port ); client.Connect (remoteEP);
What I can't get a grip on is the long timout period if the server does not respond.
I've tried adding:
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 500); client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 500);
but this does not help...
Is there a way of controling the timeout on connect?
/Johan
Sorry, of course the second "client.SetSocketOption" stated ReceiveTimeout,
I just made a typo.
None of these work...
Johan.
"David Hoerster" <Da***********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com... Did you try setting ReceiveTimeout also?
David.
"Johan" wrote:
Hi
I'm working with sockets and I'm curious about the timout when trying to connect to a server on a specific port.
My code looks like this:
Socket client = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp); int port = Int32.Parse( TextBox_Port.Text ); string ip = TextBox_IP.Text; ipAdd = IPAddress.Parse( ip ); remoteEP = new IPEndPoint ( ipAdd, port ); client.Connect (remoteEP);
What I can't get a grip on is the long timout period if the server does not respond.
I've tried adding:
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 500); client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 500);
but this does not help...
Is there a way of controling the timeout on connect?
/Johan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Achim Domma |
last post by:
Hi,
I'm using Python 2.3s timeout sockets and have code like this to read a page
from web:
request = ...
self.page = urllib2.urlopen(request)
and later:
|
by: Thomas Hervé |
last post by:
My problem is not really python specific but as I do my implementation
in python I hope someone here can help me.
I have two programs that talk through a socket. Here is the code :
<server>...
|
by: Russell Warren |
last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it
a cross-process/system setting or does it stay local in the application
in which it is called?
I've been testing this and...
|
by: Robert A. van Ginkel |
last post by:
Hello Fellow Developer,
I use the System.Net.Sockets to send/receive data (no
tcpclient/tcplistener), I made a receivethread in my wrapper, the
receivethread loops/sleeps while waiting for data...
|
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...
|
by: djc |
last post by:
I read a network programming book (based on framework 1.1) which indicated
that you should 'never' use the RecieveTimeout or the SendTimeout 'socket
options' on TCP sockets or you may loose data. I...
|
by: jnair |
last post by:
When using socket.socket.settimeout we normally only guard against
"socket.timeout" exception.Now the implementation of "settimeout" in
"Python-2.4.3/Modules/socketmodule.c" sets the socket fd to...
|
by: Robin Becker |
last post by:
While messing about with some deliberate socket timeout code I got an unexpected
timeout after 20 seconds when my code was doing socket.setdefaulttimeout(120).
Closer inspection revealed that...
|
by: carl.rosenberger |
last post by:
Hi,
I am trying to get the following behaviour for my Socket connection:
(1) Attempt a blocked read for a defined amount of time.
(2) If a timeout occurs, because no data has been sent to the...
|
by: Heikki Toivonen |
last post by:
M2Crypto has some old code that gets and sets socket timeouts in
http://svn.osafoundation.org/m2crypto/trunk/M2Crypto/SSL/Connection.py,
for example:
def get_socket_read_timeout(self):
return...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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,...
| |