Questions tagged [asyncsocket]

Asynchronous sockets allow for multiple simultaneous non-blocking socket connections.

Asynchronous sockets allow for multiple socket connections within a single thread. While more complicated than synchronous sockets, asyncsockets allow for more efficient use of cpu scheduling. These connections are non-blocking, which allows the main program thread to continue running, while a socket thread manages network traffic.

589 questions
0
votes
3 answers

Can I convert the following to TPL code?

I have the following loop that notifies a list of observers of a certain event: foreach (var observer in registeredObservers) { if (observer != null) { observer.OnMessageRecieveEvent(new ObserverEvent(item)); } } Is there A way…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
0
votes
1 answer

Receive data from socket - debug gone and code hangs

I followed the example in MSDN about C# socket programming. private static void StartClient() { // Connect to a remote device. try { // Establish the remote endpoint for the socket. // The name of the // remote device is…
Mike Stone
  • 319
  • 9
  • 22
0
votes
1 answer

iOS: read and write in a socket (tcp connection)

In my app I should comunicate with a server side (a little device that do as a server). My principal operation is to write a sequence of 17 byte and read the result. I used GCDAsyncSocket but it don't give me ever a good result. I want ask to you if…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
0
votes
2 answers

Send binary data and read the values of that using async socket programming

I am trying to send data to a server from my client .the client sends messages to a server ,every message is 36 bytes and in this message every 4 byte is a field and in server part i should be able to detect that field from the message that client…
Ehsan Akbar
  • 6,977
  • 19
  • 96
  • 180
0
votes
2 answers

Google Go EOF on reading from connection using Read()

I am trying to create a simple TCP server using the Google Go language. I have a client which points to 127.0.0.1:8484. When my server code tries to read the buffer I receive an EOF error on line 37. The client sends an initial tcp packet denoting…
John
  • 343
  • 2
  • 5
  • 15
0
votes
1 answer

How async Socket.EndReceive know the number of bytes it read? And how does async socket finish reading?

I have this code _socket.BeginReceive( _buffer, 0, _buffer.Length, SocketFlags.None, _asyncCallback, sSocketName); **with** _buffer.Length = 262144; _asyncCallback = OnReceive; sSocketName is a…
Vu Nguyen
  • 3,605
  • 3
  • 22
  • 34
0
votes
1 answer

CAsyncSocket and sending/transmitting data with notifications

I use CAsyncSocket with events, for example I overwrite OnReceive(). However, I am not completely clear at which "level" this should be implemented. For example, the other end could send data byte-by-byte; OnReceive would then be called after every…
divB
  • 896
  • 1
  • 11
  • 28
0
votes
1 answer

Can CAsyncSocket be reused?

When I use CAsyncSocket, can I reuse the same object for another connection (by closing and opening again), or should I create a brand-new object for each connection?
divB
  • 896
  • 1
  • 11
  • 28
0
votes
1 answer

CAsyncSocket::Receive returns WSAENOTSOCK

I use a trivial CAsyncSocket to implement a TCP server. I cannot see any mistake here. Still, Receive returns WSAENOTSOCK: class CMyWnd : CWnd { CMySock m_sListener; CMySock m_sConnected; } CMyWnd::CMyWnd() { m_sListener.SetWnd(this); …
divB
  • 896
  • 1
  • 11
  • 28
0
votes
1 answer

How to analyze the AsyncSocket readDataToLength to a corresponding Wireshark TCP packet?

For example I have a AsyncSocket *sock, and I tried to do a socket read: [sock readDataToLength:BUFFER_SIZE withTimeout:_timeout tag:0]; On the other hand, I have do a Wireshark sniffer for this network. How do I figure out this socket read…
srjohnhuang
  • 232
  • 5
  • 18
0
votes
0 answers

deserializing error occured

I'm trying to deserializing to DataFromServerToClient object that I designed. but It doesn't work. I said sirialized keyword to every classes that it has as fields. exception message is version=1.0.0.0 culture=neutral publickeytoken=null what am I…
0
votes
1 answer

Async socket server with multiple clients connected

I want to write a asynchronous socket server and client in C#. The server has to manage many client connections and keep them alive as long as it's possible. I tried using MSDN server code from this site, but it cant handle multiple clients at the…
bartekmp
  • 403
  • 3
  • 9
  • 21
0
votes
3 answers

AsynchronousSocketChannel write/read all messages in one

Respect, I try to use new Java NIO2 to create Asynchronous SocketChannel on the client and on the server side and communicate, but problem is that all messages I sent to socket on the server, socket read all as one message. here is code: I create…
user2803095
  • 347
  • 1
  • 4
  • 16
0
votes
0 answers

c# How to synchronize socket Asynchronous Receive data from web page

class testDemo { public string ResponseContent; /// /// Get the new data and send it out to all other connections. /// Note: If not data was recieved the connection has probably /// died. /// ///…
0
votes
1 answer

NSThread, AsyncSocket and object deallocation

I have a piece of network code that uses AsyncSocket but moves it to a separate runloop. I'm creating this runloop with the following piece of code: [NSThread detachNewThreadSelector:@selector(_workerLoop) toTarget:self withObject:nil]; and here's…
esad
  • 2,660
  • 1
  • 27
  • 23