tcpclient

.NET NetworkStream closed, how to be sure all data is read?

扶醉桌前 提交于 2019-12-11 06:28:30
问题 I've an open TCP connection, and reading using NetworkStream.BeginRead(). Once the connection is closed at either end, the callback is called and the stream object is useless - like documentation says, EndRead() throws IOException or ObjectDisposedException depending in this case on which end terminated the connection. Is it guaranteed that there isn't any data I'm missing just in between the last successful EndRead (and the re-BegingRead) and disconnection, particularly if I do it at my end?

TCP client in ASP.net

半腔热情 提交于 2019-12-11 06:22:22
问题 i'm trying to connect from asp web application to tcp server. I did this using application in C#, and now i'd like to see if it will be working from web browser. My code is: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Net; using System.Net.Sockets; namespace TcpWebClient { public partial class

Connect to a TCP server via TcpClient through proxy

廉价感情. 提交于 2019-12-11 05:24:55
问题 My system is accessing internet via a proxy server (IE proxy server address : myserver.mydomain.com , port: 80). Im trying to send some data to a TCP server using class "System.Net.Sockets.TcpClient" . But i am unable to connect. If I try using static IP internet, i am able to connect. Is there any way to provide proxy address ? I am pretty sure the problem is the proxy, because i have tried from two systems which do not use proxy and it worked fine. My application is a console application.

NetworkStream doesn't always send data unless I Thread.Sleep() before closing the NetworkStream. What am I doing wrong?

一世执手 提交于 2019-12-11 04:55:15
问题 I'm having problems sending a very small piece of data (a date) to another TcpClient running on the same computer. In the code below you will see that it sleeps before closing the NetworkStream. If I remove the Sleep it causes an intermittent problem where the data doesn't turn up at the other end. Am I doing something wrong here? using (TcpClient client = new TcpClient()) { client.Connect(new IPEndPoint(IPAddress.Loopback, _tcpServerPort)); NetworkStream clientStream = client.GetStream();

The data to be decrypted exceeds the maximum for this modulus of 128 bytes

最后都变了- 提交于 2019-12-11 04:32:06
问题 I'm trying to establish a secure connection between a Client and a Server with RSA/AES (i think you know how that works) now my Problem is, i get that error message written in the title. I know, there are 2 or 3 other threads with the same title, but all of them try to en- and decrypt from a file on the pc. i get that error at the encryption of the AES key which was encrypted using the RSA public key which is the normal way to do as i know. here my "Client" and "Server" applications Client:

How to implement TCP KeepAlive in VB.NET on a TCP Client(socket)

余生长醉 提交于 2019-12-11 03:32:40
问题 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? For the moment i have enabled the TCP KeepAlive option! tcpsocket.Connect(IPEndPoint) tcpSocket.SetSocketOption(SocketOptionLevel.Tcp,SocketOptionName.KeepAlive,1); Searching on the internet i have found

Sending large objects over TCP: “End of Stream encountered before parsing was completed”

放肆的年华 提交于 2019-12-11 03:17:09
问题 I keep getting an SerializationException whenever I try to deserialize a list of doubles from a NetworkStream : End of Stream encountered before parsing was completed I have a simple client server architecture: my TcpTransportClient wraps the functionality of a TcpClient and I utilize two basic methods: Send (sends a message) and Receive (blocks until a message is received). The Send function takes a Message , serializes it using a BinaryFormatter and sends the bytes via the NetworkStream .

Recive different type of objects on the same TCP socket

只谈情不闲聊 提交于 2019-12-11 01:55:21
问题 so here is the deal: I have a server running that is constantly accepting clients by TCP socket: public ArrayList<Socket> lista_users = new ArrayList<Socket>(); Socket s; s = serverSocket.accept(); lista_users.add(s); avisa_all(lista_users, s); Thread t_trata_cliente = new Thread(new trata_cliente(lista_users, s)); t_trata_cliente.start(); //this Thread is responsable for interacting with //the clients (where my question is) Saving the sockets on array list. After i want to send different

How much buffer does NetworkStream and TcpClient have?

♀尐吖头ヾ 提交于 2019-12-10 15:32:45
问题 We are writing a TCPServer and Client program. How much space is there in the TcpClient buffer? Like, at what point will it begin to throw away data? We are trying to determine if the TcpClient can be blocking or if it should go into it's own background thread(so that the buffer can not get full).. 回答1: You can get the buffer sizes from TcpClient.ReceiveBufferSize and TcpClient.SendBufferSize . The available buffer sizes will vary as data is received/acknowledged(or not) at the TCP level.

Android TCP connection best practice

≡放荡痞女 提交于 2019-12-10 12:35:29
问题 I am working on an Android application that requires a TCP connection to a TCP server(Written in Node.js) My Android TCP client is working an can send messages back and forth. My spesific questions is: What is the best way to handle a TCP connection to a server in Android ? How to maintain the connection(close the connection properly on onDestroy() etc) ? Is there any bether way then using an AsyncTask(Except a normal Thread class, which is not allowed in Android 4.0) I have my socket