I'm doing some stress test for some TcpIP communication.
rougly it's someting like that:
for(i=0; i<1000; i++)
{
Sockect s = new Socket()
s.Connect(endPoint);
NetworkStream ns = new NetworkStream(s);
// .... read / write about 10k random bytes
....
ns.Close();
s.Close();
}
the problem is sometimes (usually at the 994th iteration, but not always) I
have a socket exception on Connect()
(NativeErrorCode: 10048, only one socket could listen at a given
address/port) ???
It's a client socket, and I don't bind it at all !!! 6 2435
Lloyd, could you post a working, simple sample which demonstrates what you
are seeing? A simple command line app would be perfect.
--
Greg Ewing [MVP] http://www.citidc.com/
"Lloyd Dupont" <net.galador@ld> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl... I'm doing some stress test for some TcpIP communication. rougly it's someting like that:
for(i=0; i<1000; i++) { Sockect s = new Socket() s.Connect(endPoint);
NetworkStream ns = new NetworkStream(s); // .... read / write about 10k random bytes .... ns.Close(); s.Close(); }
the problem is sometimes (usually at the 994th iteration, but not always)
I have a socket exception on Connect() (NativeErrorCode: 10048, only one socket could listen at a given address/port) ??? It's a client socket, and I don't bind it at all !!!
On Sat, 11 Oct 2003 02:12:59 +1000, "Lloyd Dupont" <net.galador@ld> wrote: s.Close();
The socket handles don't go away immediately, and so it sounds as if you're
running out.
--
What the caterpillar calls the end,
the rest of the world calls a butterfly.
~ Lao-tzu
Components For Thinkers www.abderaware.com
zane @at@ abderaware .dot. com
This is a known issue. You are running out of "wildcard" ports. When you do
a connect the socket uses a wildcard port for receiving data. Each
connection goes into a "TIME_WAIT" state to prevent immediate re-use of the
port. This is by design to prevent port hijacking. The port becomes
available again after two minutes. If you do a "netstat -a" when you notice
the socket Exception you'll see lots of connections in the "TIME_WAIT"
state.
The workaround is to do a System.Threading.Thread.Sleep for ~2 minutes when
you get close to 1000 connections.
-Ron
"Lloyd Dupont" <net.galador@ld> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl... here you go, the stress client and server. compile with: csc /nologo /out:client.exe StressTest.cs StressClient.cs csc /nologo /out:server.exe StressTest.cs StressServer.cs
and run server & client in 2 different console, although I would advise
you to run client with a debugger, to catch the exception.
when I run client multiple time it bug, randomly, about every second times....
"Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> a écrit dans le message de news:Oa**************@TK2MSFTNGP12.phx.gbl... Lloyd, could you post a working, simple sample which demonstrates what
you are seeing? A simple command line app would be perfect.
-- Greg Ewing [MVP] http://www.citidc.com/ "Lloyd Dupont" <net.galador@ld> wrote in message news:OJ**************@TK2MSFTNGP11.phx.gbl... I'm doing some stress test for some TcpIP communication. rougly it's someting like that:
for(i=0; i<1000; i++) { Sockect s = new Socket() s.Connect(endPoint);
NetworkStream ns = new NetworkStream(s); // .... read / write about 10k random bytes .... ns.Close(); s.Close(); }
the problem is sometimes (usually at the 994th iteration, but not always) I have a socket exception on Connect() (NativeErrorCode: 10048, only one socket could listen at a given address/port) ??? It's a client socket, and I don't bind it at all !!!
ho, ok.
thanks for the info.
I had an excellent work around since then, anyway ;-)
"Ron Alberda [MSFT]" <ro*****@online.microsoft.com> a écrit dans le message
de news:ef**************@tk2msftngp13.phx.gbl... This is a known issue. You are running out of "wildcard" ports. When you
do a connect the socket uses a wildcard port for receiving data. Each connection goes into a "TIME_WAIT" state to prevent immediate re-use of
the port. This is by design to prevent port hijacking. The port becomes available again after two minutes. If you do a "netstat -a" when you
notice the socket Exception you'll see lots of connections in the "TIME_WAIT" state.
The workaround is to do a System.Threading.Thread.Sleep for ~2 minutes
when you get close to 1000 connections.
-Ron
"Lloyd Dupont" <net.galador@ld> wrote in message news:ul**************@TK2MSFTNGP12.phx.gbl... here you go, the stress client and server. compile with: csc /nologo /out:client.exe StressTest.cs StressClient.cs csc /nologo /out:server.exe StressTest.cs StressServer.cs
and run server & client in 2 different console, although I would advise you to run client with a debugger, to catch the exception.
when I run client multiple time it bug, randomly, about every second times....
"Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> a écrit dans le message
de news:Oa**************@TK2MSFTNGP12.phx.gbl... Lloyd, could you post a working, simple sample which demonstrates what you are seeing? A simple command line app would be perfect.
-- Greg Ewing [MVP] http://www.citidc.com/ "Lloyd Dupont" <net.galador@ld> wrote in message news:OJ**************@TK2MSFTNGP11.phx.gbl... > I'm doing some stress test for some TcpIP communication. > rougly it's someting like that: > > for(i=0; i<1000; i++) > { > Sockect s = new Socket() > s.Connect(endPoint); > > NetworkStream ns = new NetworkStream(s); > // .... read / write about 10k random bytes > .... > ns.Close(); > s.Close(); > } > > the problem is sometimes (usually at the 994th iteration, but not
always) I > have a socket exception on Connect() > (NativeErrorCode: 10048, only one socket could listen at a given > address/port) ??? > It's a client socket, and I don't bind it at all !!! > >
What was your excellent work around?
Roy
"Lloyd Dupont" <net.galador@ld> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl... ho, ok. thanks for the info. I had an excellent work around since then, anyway ;-)
sorry for this late answer, I didn't touch my computer lately.
well the workaround is simple, I juste create one socket ;-)
I use a connected mode, I oen a bunch of client to my server and kept them
open and reuse them.
it runs very well and local test were twice as fast.
the coding were much longer though (there is lot of sofistication working
transparently like async read/write, auto-reconnection, message queuing and
home made thread pool ...)
"Roy Green" <ro******@mindspring.com> a écrit dans le message de
news:u0**************@TK2MSFTNGP11.phx.gbl... What was your excellent work around?
Roy
"Lloyd Dupont" <net.galador@ld> wrote in message news:u3**************@TK2MSFTNGP09.phx.gbl... ho, ok. thanks for the info. I had an excellent work around since then, anyway ;-)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: simon place |
last post by:
Spent some very frustrating hours recoding to find a way of closing a server
socket, i'd not thought it would be any problem,
however, after complete failure and as a last resort, i looked at the...
|
by: DreJoh |
last post by:
I've read many articles on the subject and the majority of them give the same
solution that's in article 821625 on the MSDN website. I'm using the
following code and when a the client disconnects...
|
by: roger beniot |
last post by:
I have a program that launches multiple threads with a ThreadStart
method like the following (using System.Net.Sockets.Socket for UDP
packet transfers to a server):
ThreadStart pseudo code:
...
|
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: Macca |
last post by:
Hi,
I have a synchronous socket server which my app uses to read data from
clients.
To test this I have a simulated client that sends 100 byte packets.
I have set up the socket server so...
|
by: Macca |
last post by:
My app has an asynchronous socket server. It will have 20 clients connected
to the server. Each client sends data every 500 millisecondsThe Connections
once established will not be closed unless...
|
by: Macca |
last post by:
Hi,
I am writing an asychronous socket server to handle 20+ simulataneous
connections.
I have used the example in MSDN as a base. The code is shown at end of
question.
Each connection has a...
|
by: BuddyWork |
last post by:
Hello,
Could someone please explain why the Socket.Send is slow to send to the same
process it sending from. Eg. Process1 calls Socket.Send which sends to the
same IP address and port, the...
|
by: darthghandi |
last post by:
I've created a class to listen to all interfaces and do a
BeginAccept(). Once it gets a connection, it passes the connected
socket off and stores it in a List. Next, it continues to listen for...
|
by: O.B. |
last post by:
I have a socket configured as TCP and running as a listener. When I
close socket, it doesn't always free up the port immediately. Even
when no connections have been made to it. So when I open...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: 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...
| |