.net - Socket.AsyncSend Behavior When Remote Client Stops Receiving

Mar 6, 2011

I'm running into an issue where I have a lot of AsyncSends going on with dozens of client sockets, and at the moment if any remote client stops receiving but doesn't actually disconnect, the app quickly eat sup all of the SocketAsyncEventArgs (aka an sae) I have preallocated because they're not released since the SendAsync is not completing. The obvious solution to this is to implement a per-client send queue, which sounds easy enough but I am unclear as to the specifics. I have one sae allocated per client to receive, which works perfect, and ideally I'd love to allocate a single sae to the client's async sends.

I understand popping in and asking a question that is veiled request for a 'give me code' solution is looked down upon, but I honestly have not been able to turn up a lot, either on the .XAsync methods, which Microsoft has a horribly poor example for, nor for a send queue in general.

Edit for @J.N.

I forgot to mention it, but I -am- actually using a bunch of preallocated sae's stored in a managing class that internally uses a ConcurrentBag. With one connection, in a test scenario where 20 small messages are sent per second (this is slightly more than double how many messages would actually be sent in the production server), the server eats up 500 preallocated sae's in a few seconds. If I implement 'create if empty' code, the sae count quickly climbs into the thousands.

I understand the functionality that the async methods of the Socket class provides, but if there's a network hiccup or something similar, this issue will outright bomb the server within seconds. A send queue sounds like an great solution, but I have no idea whether it's a good idea to do in a high performance production environment or not.

The base problem remains, though, that with a dozen messages per second per client being sent out, any network congestion or other factor that lags the connection but does not disconnect it will quickly deteriorate into a laggy mess.

I think a solution I might be looking for is something that locks up the single sae being used for sending until the completion callback is reached, where that sae is then unlocked and then reused to send any pending data. The actual implementation of it eludes me though.

View 1 Replies


ADVERTISEMENT

Client Socket - Send Message Through Client Socket Receive Specified Argument Was Out Of Range Of Valid Values

Oct 15, 2011

Below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes("0800822000000000000004000000000000000920092126012345001")

[CODE]...

View 1 Replies

Identify Connection Lost Between Socket Server And Socket Client?

May 21, 2011

I wrote a Socket Client which will send the Socket Server some data and get some response from Server. This process will be running once in every 2 seconds.

Now what I need to know is How we can identify the connection lost between Server and Client?

I need this to be implemented in the Client side. If there is no connection then Client should automatically close the connection. Once the connection with the server is available in the next attempt it should connect automatically.

View 1 Replies

Data Receiving With Socket?

Sep 27, 2011

i am working on 3rd party chat software, when ever i send data to server i get incorrect buffersize of data. like when i convert that data to hex to matching header for splitting data i got huge lengths data

in the above textbox of image i have got some 0000000000000000000.... with the hex data, how can i get only only original data. The code i have used to receive data is

[Code]...

View 1 Replies

How To Dynamically Allocate Buffer For Receiving UDP Socket

Feb 20, 2010

A friend and I are working on a project where we're required to build a reliable UDPclient/server using VB.Net. We have things working well, but one thing that still eludes us is how to dynamically allocate a (byte) buffer for the incoming data. Right now we have to hard code a maximum value/MTU (or use a really large buffer size and resize it once we've finished receiving). Does anyone know of a way that this can be done without needing to specify the receive buffer size?

Basically, before calling the receive function on the socket with a buffer of size x, we want to know x so we can allocate an appropriately sized buffer. Perhaps this is a problem in all socket programing that you just have to deal with??

View 1 Replies

VS 2010 Socket Chat Is Not Receiving On Java Server

Aug 17, 2011

I am making a java chat server, and a guy was able to connect to it no problem (however, he logged off for the night before I ran into any problems, so I couldn't see what he did). Here is my code on the VB form:

[Code]....

View 5 Replies

Socket Programming And Telnet Class For .NET To Simplify The Sending And Receiving Of Data?

Sep 28, 2009

I'm writing a GUI-based app in VB.net that talks to a LambdaMOO server via telnet, sends commands to display the object hierarchy, then parses the output and creates a visual representation of the object hierarchy.So my question is: is there some kind of "telnet client" class for .NET to simplify the sending and receiving of data, or do I have to write my own using the socket API?

View 7 Replies

Public Properties Within VB Module - Cross-client Behavior

Oct 15, 2010

Can one client call a public property within a VB.NET module and see the value of that public property changed by another client accessing it at the same time?

[Code].....

I'm running into random instances where it looks like another client might be modifying (by setting) the value of GetSetDateTime DURING the first client's run through of WhateverMethod(). This is alarming to me and I've been trying to figure out if that's a possibility.

View 2 Replies

TCP Client Receiving Data?

Dec 6, 2009

I have made this code:

Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("usuarios.lycos.es", 80)

[Code]...

View 4 Replies

How To Check If Client Socket Has Disconnected

Apr 13, 2009

i am using the client/server classes for file transfer by moeur.what i want to know is that once my client is connected to the server and after that the client machine goes off the network. now when my server trys to send a file or some message to the client i am not able to trap the error that the client is disconnected.how to do this. there might be a case where the client machine suddenly shuts down. in such cases how will my server know that the client has disconnected.

View 2 Replies

VS 2005 StackOverflowException In Socket Client?

Apr 6, 2010

I'm working on a simple socket client application that transfers files from one PC to another. The flow is as follows.

Client sends message to Server
Client Listens for response
Server responds with command
Client sends file or message to Server
Client Listens for response

This sequence will repeat thousands if not tens of thousands of times. It runs great on my dev box but when I load it on another machine I get a StackOverFlowException. I know why I'm getting the stack overflow. It's because I have a Listen subroutine that calls a Send routine. When the Send routine is done it calls the Listen routine again. The process works for about 614 iterations and then bombs out with a stack overflow. I guess my question is, how can I code a socket application that can send-->listen-->send-->listen thousands of times without blowing the stack?

View 1 Replies

Remote Desktop Api - Setup Port Listening Socket

Sep 30, 2010

I'm writing a remote desktop software that starts a connection in reverse mode, using RDP API. My problem is that I try to setup the port that the listening socket may use, but it seems not working: it uses always a random port. [Code] The problem is the seems PortId is ignored: my connection string reports other ports number, and the incoming socket is open on port different from 4000.

View 1 Replies

Client Server Winsock Or Socket Programming?

Jul 14, 2009

how to access client side activity i.e. which client is connected and which computer connected at the same time from server.

View 1 Replies

Implement TCP KeepAlive In Program On A TCP Client(socket)?

Apr 24, 2012

I want to implement the TCP KeepAlive in order to check dropped connections by running a timer.

In my case, I have a TCP Client (using socket class) and a third party server (i have no control on it).

How can i use the TCP KeepAlive on my TCP Client in order to check the connection state?[code]...

View 1 Replies

Managing Multiple Client Socket Connection?

Sep 11, 2011

Am developing a server - client application using the system.net class , that will have more than 5000 simultenous client connection.what is the best way to manage multiple client connection like this?

View 3 Replies

Threading Windows Service TCP Socket Client?

Jan 22, 2012

I'm trying to build a multithreaded SMPP client with VS2008 and I'm getting bogged down in threading. Basically my main parent thread will interact with the windows service scheduler, get registry settings, and get a list of SMPP servers to connect to. Then it will launch a thread for each SMPP connection, which will need to keep it's TCP socket open to receive messages with, so the thread must remain running even if there aren't any events happening (no messages to receive)... but I can't seem to get it figured out.

[Code]...

The Start sub in the oChannel object does run, but once that sub is finished running the thread ends. In the Start sub, it calls other code that initiates a connection to the remote SMPP server, but that code asynchronously waits for an event to be raised regarding the connection status. Once the sub finishes, the async connection being attempted doesn't seem to be able to pin the thread down.

View 3 Replies

.net - Check The Connection State Of A TCP Server (Socket) With TCP Client?

Apr 23, 2012

For almost a week I am reading and trying to find a solution for checking connection state using a TCP Client (using socket class) In my scenario I have a TCP Client that is connected to a server (it is not controlled by me) and i want that from time to time to check the connection state, and reconnect if necessary.I have read a lot of information on the internet but i did not find a suitable solution.Briefly, these are the methods that i have found on the internet and try to implement.But unfortunatelly, i have found some scenarios where the TCP Server is closed and the TCP Client is still saying Connected 1.Example from MSDN

[code]...

View 1 Replies

Get The Client Connection Parameters Of The Socket On Server Side?

Sep 13, 2011

I want both the client and server to write and read resp. at a constant rate (which can be configured on the GUI of the client) to the buffer.I am able to send from the client at 150 bytes per packet Now, I should be able to read also at 150 bytes per packet on the server too Since, both are connected through a socket, can we retrieve the socket params (set on the client size, like 150 here) from the server end, using the tcpServer object.Or is it must to send an initial setup packet which tells about these client params and so accordingly the server can continue?

View 1 Replies

TCP Client Error While Reading Data From Socket Server?

Apr 20, 2012

I have a TCP Socket Client (using the Socket Class) that is connected to a simple TCP socket server (just for testing)I have this code snippet :

Dim aSocket as Socket
While aSocket.Connected = True
byteRead = aSocket.Receive(dataByte) 'number of bytes

[code].....

View 1 Replies

Specific Cast Is Not Valid In Client Server Socket Program

Jun 14, 2012

I am Working on Teghax Component.Using This Component we want to find out Block title attribute of dwg file in a client server socket application.

1> We get Block title attributes properly of dwg file in windows application form using the getattribute function().

2> We get Block title Attributes properly in that way:-We take a class library where we take a class.in this class we use getattribute function().Then We access the particular class from another project

But when we use the same class(Keep same structure) in client server socket program.Then it gives an exception.i.e ,"Spaicfied cast is not valid"I am Not getting any reply form teghax developer..I attached exception screen sort.Give me Suggestion How to solve this Exception

Code given Bellow :

Public Function Get_DwgFileAttribute(ByVal Sender As ClsTcpConnection, ByVal msgTag As Byte, ByVal message As String) As String
Dictionary = GetHashtable(message)
Dim varfilepath As String = CStr(Dictionary.Item("filePath"))

[code]....

View 1 Replies

VS 2010 TCP Chat Server Closes Socket On Client DisConnect?

Jun 24, 2010

I am working on a chat client and server, and so far it works well, but when I close the client, the server throws an exception because it continues to try to do processes on the disconnected client. I have tried adding clientSocket.Close() in various places throughout the client and server with no luck. Does someone know how to add the disconnect code to either the server or client with this code?Server:

Imports System.Net.Sockets
Imports System.Text
Module Module1

[code].....

View 5 Replies

Asynchronous Socket Programming Vb 2008(.net) Again Server Should Able To Send The Data To Client

Feb 2, 2011

I am facing problem in asynchronous socket communication.

1)I wanted to perform connect(from client to server) operation on enter button and send the data whatever client want to send and disconnect from server. And again client should get connect to server whenever client wanted to send data. this is the mechanism.

i.e how to reuse the socket.

2)Again Server should able to send the data to client.

View 5 Replies

Communications :: Socket Behaviour - Created A Client That Can Send And Receive Data Via TCP Sockets

Aug 26, 2010

I have created a Client that can send and receive data via TCP sockets. The objects stored on the serverside are the *exact* same object used for the client. They use the same send and receive protocols.

Now, when i send a string from the server to the client , it does precisely what it should do. However when I send a string to the server.... I do receive the string as an equal length of NULL characters. I run the server and client locally.

Basicly what can influence the behaviour between two completely identical objects performing the exact same task? I wonder if there is some socketflag issue if the TCPlistener.accept function returns a completely different setup then the one I R used to.

(if it is of any interest, the send protocol is asynchronious)

View 3 Replies

Remote Desktop Client?

Oct 17, 2011

Both I and a Friend are working on a Visual Basic Remote Desktop Client, we've got as far as laying it out the way we want it but are unsure of how to code the program. Can anyone shed some light upon what we could use to make our program generate an ID which another user can enter at their site to connect to the computer?

View 1 Replies

.net - Tcp Client Not Receiving The Entire Data Response Data From Server?

Apr 19, 2011

I have a small program which is a tcp client. I send a string from this client to a device over ethernet (it acts as the tcp server). As soon as the device recieves the input string it will respond back with response data. My problem is i am not getting the entire response data back from the server. (device).

Dim serverStream As NetworkStream = clientSocket2.GetStream()
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("my-cmd")
serverStream.Write(outStream, 0, outStream.Length)

[code]....

View 4 Replies

Copy File From Client To Remote Server?

May 7, 2010

I'm trying to upload a file to a remote server by using vbscript

below is a code :

Dim fso, f, myFile
Set fso = CreateObject("Scripting.FileSystemObject")
myFile =$URL

[code]....

the problem is with this code i can copy the file only in the same PC but it didn't work when i try with different machin i mean from client to server?

View 3 Replies

Remote Desktop Client (RDP) In Form / TabControl?

Jun 17, 2011

I woudl like to use a the RDP control in my form. However, when I add the Active-X object and open the form during runtime with frm.show() the app fails.

There are several apps available who do excatly the same. How can I get this running?

View 5 Replies

Cannot Get The Correct Buildnumber Of The Remote Desktop Services Client

Jul 6, 2010

I want to use the c# write a programe to get the logon session information.I use the WTS_INFO_CLASS Enumeration refrenced to the msdn library,the url link is [URL]

Everything is ok except the WTSClientBuildNumber property. The WTSClientBuildNumber that I get is 5875288,but it should be 6001.I use the 6.0.6001 RDC for my test.Can anyone tell me the problem.

The following is my sample code

If WTSQuerySessionInformation2(ptrOpenedServer, active_session, WTS_INFO_CLASS.WTSClientBuildNumber, istr, returned) = True Then
ClientInfo.WTSClientBuildNumber = istr.ToString()
End If

View 1 Replies

VS 2008 Application Remote Control (client/server)?

Oct 16, 2010

I need some pointers on which .NET technology to use for a project I'm working on. I'm building a "dashboard" digital signage WPF program that will display various things on a large monitor mounted high up in the ceiling of my office.What I need to be able to do is control certain aspects of this program from my desktop. For example, there will be a TV window in the application with signal being provided by a TV tuner on the mini-computer connected to the monitor in the ceiling. What I want to be able to do is make a remote control to be able to change the channel etc. I'm confused at what technology to use. I've read about remoting, WCF, and simple TCPclient classes but I'm confused at which one would be better. I'm thinking it may be better to use WCF because what I think I need to do is make a function that will change the channel and accept channel numbers, etc from the remote control program. Am I on the right path?

View 5 Replies

[2008] Remote Client - Send The Image To Other Computer?

Jan 15, 2009

Well I'm start making a server and client program of chat and send image desktop. I have some questions i would like to make. 1 What is the best way to make a connection between machines?? Sockets??? 2 How can i send the image to other computer? With buffer stream?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved