|
|
Rank: Member Groups: Member
Joined: 8/12/2009 Posts: 3 Points: 9 Location: Mexico
|
I tried to create a pool of sockets in VB.NET using the following code but the listener does not create well (sometimes it does other does not). The pool (class array) is about 700 sockets and it creates 350 listeners aprox. (50% of efficiency) I am using windows 2003 server when this behavior arraise. In the developer workstation it works good. I tried to destroy the class and recreate it again but it does not work. Any idea.
Public Sub StartServer(ByVal IP As String, ByVal Port As Integer)
Dim ep As IPEndPoint Dim extended As New ExtendedParameters
ep = New IPEndPoint(IPAddress.Parse(IP), Port) extended.BufferSize = 1024 extended.Optimized = False Try listener = Network.AcceptAsync(ep, AddressOf ProcessClient, extended) Catch ex As Exception Debug.WriteLine(ex.Message) mException = ex.Message End Try End Sub
Private Sub ProcessClient(ByVal connection As XF.IConnection) connection.ReadAsync(AddressOf ReadComplete) End Sub
Private Sub ReadComplete(ByVal connection As XF.IConnection, ByVal buffer As XF.IMemoryBuffer)
If IsNothing(buffer) Then Exit Sub End If
' acquire buffer to use it in asynchronous operation buffer.Acquire()
'-- Convert the buffer to a string Dim Receive As String = m_Encoding.GetString(buffer.Data, 0, buffer.BytesTransfered)
Debug.Write(Receive) mConnection.WriteAsync(buffer.Data, buffer.Offset, buffer.BytesTransfered, AddressOf WriteComplete)
buffer.Release()
' continue processing client requests */ ProcessClient(connection) End Sub
Best regards,
Jorge Reyes
|
|
Rank: Administration Groups: Administration
Joined: 2/15/2008 Posts: 130 Points: 835
|
Hi Jorge,
What is the reason to create so many listeners? What exactly do you want to implement?
|
|
Rank: Member Groups: Member
Joined: 8/12/2009 Posts: 3 Points: 9 Location: Mexico
|
Hi Admin,
We have developed a system to monitor vehicles using gps and each device is a client socket using a dedicated port, therefore the counter part is the socket server hearing (listeners). There are 2 approaches to solve this issue to connect all the devices to one port and the logic identifies each one or the multiport approach. For this project we must use the multiport.
It is very weird because in my development machine (Vista with Visual Studio 2008) the sockets create without problem but when i run in win 2003 the problem is present.
Do you have an advise to follow trying to solve this issue ?
|
|
Rank: Administration Groups: Administration
Joined: 2/15/2008 Posts: 130 Points: 835
|
Jorge,
By default each listener creates a pool of prepared sockets (by 256 until there are at least 1024 sockets). So you system has used all the resources.
How many simultaneous connections do you get on one listener? Is it just one?
I would suggest to set: ExtendedParameters.DeltaConnections = 4; ExtendedParameters.MinimumPreparedConnections = 4;
In this case you will use less resources for each listener and can create more listeners.
|
|
Rank: Member Groups: Member
Joined: 8/12/2009 Posts: 3 Points: 9 Location: Mexico
|
Dear Administrator
I could create my socket with your recommendation. Thank you for your support. I have a doubt because the manual is not ready yet. What is DeltaConnections property intended for ?
Best regards Jorge Luis
|
|
Rank: Administration Groups: Administration
Joined: 2/15/2008 Posts: 130 Points: 835
|
DeltaConnections property defines how many connections should be prepared at once.
|
|
|
Guest |