tcpclient

C# - Socket to log on to Firewall

。_饼干妹妹 提交于 2019-12-04 05:04:21
问题 I wrote an app to automatically connect to our different Firewalls. All of them work with the same frontend. We telnet to the IP and they give the message LOGIN or LOGOUT and ask for a username or password. I used this code: public static void ConnectToFirewall(string strUsername, string strPassword, string strFirewallIp) { IPAddress[] ipaIpAddressCollection = Dns.GetHostAddresses(strFirewallIp); IPEndPoint ipeIpEndPoint = new IPEndPoint(ipaIpAddressCollection[0], intPort); Socket sckSocket =

multi client/server chat program in c#?

↘锁芯ラ 提交于 2019-12-04 04:58:20
问题 the clients will be able to chat one-to-one and in group (temperately rooms) similar to Skype. I will use the server to authorize the clients my question is which is better to go with? (WCF) or (TCPClient, StreamReader, and StreamWriter) cheesr 回答1: I would vote for WCF also, as it will provide you with a common interface for doing a client/server architecture regardless of what protocol (binding) you choose behind the scenes. For example, you could very quickly make your chat program work

New Instance of TCPClient Exception [duplicate]

有些话、适合烂在心里 提交于 2019-12-04 04:43:42
问题 This question already has an answer here : C# network connection running from shared drive (1 answer) Closed 4 years ago . I asked a similar question to this a few days ago. At that point, I was trying to use sockets. Currently, I am using TCPClient to do the dirty socket work for me. I am using Windows 7 and Visual studios 2013 Professional. Original and Current Project Outline: I need to create an application (WinForms using C#) that allows the user to connect to a device (a piece of

Reconnect TCPClient after interruption

不想你离开。 提交于 2019-12-04 04:04:26
问题 I have multiple instances of a client application, connecting to a main application over internet by TcpClient. (Both coded by me). So the connection is made like: TcpClient.Connect(ip, port) I now want this to handle various type of disconnect events: Main App (server) or a client app computer lose internet connection. On resume of connection, the communication seems lost, but when I try to reconnect, I get message: "A connection request was made on an already connected socket" So I need to

Understanding the NetworkStream.EndRead()-example from MSDN

左心房为你撑大大i 提交于 2019-12-04 03:30:42
I tried to understand the MSDN example for NetworkStream.EndRead(). There are some parts that i do not understand. So here is the example (copied from MSDN ): // Example of EndRead, DataAvailable and BeginRead. public static void myReadCallBack(IAsyncResult ar ){ NetworkStream myNetworkStream = (NetworkStream)ar.AsyncState; byte[] myReadBuffer = new byte[1024]; String myCompleteMessage = ""; int numberOfBytesRead; numberOfBytesRead = myNetworkStream.EndRead(ar); myCompleteMessage = String.Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead)); // message

Configure socket ACK timeout?

怎甘沉沦 提交于 2019-12-03 23:26:34
Is there a way to configure the timeout in which a socket expects to receive an ACK for sent data before it decides that the connection has failed? I'm aware this can be done at the application level as well, but since every packet I send is ACK'd anyway, and I just want to know if my data is received, using additional data at the application level to accomplish the same thing seems wasteful. (Not to mention, my particular application uses per-byte charged cellular links.) Note: As per my previous question -- What conditions cause NetworkStream.Write to block? -- you cannot rely on .Write

How to use Proxy with TcpClient.ConnectAsync()?

流过昼夜 提交于 2019-12-03 21:39:34
HTTP proxy support in .NET does not actually support the lower level classes like TcpClient or Socket. But I want to connect a TCPServer (ip, port) through HTTP proxy that support 'CONNECT' command. So I need to do the following steps: Connect to proxy. Send CONNECT Host:Port HTTP/1.1<CR><LF> Send <CR><LF> Wait for a line of response. If it contains HTTP/1.X 200 , the connection is successful. Read further lines of response until receive an empty line. It's connected to the outside world through a proxy. Any data exchange as posssible with proxy. Actually I do this without proxy TcpClient

When sending data larger than the SendBufferSize, how will the data be received?

核能气质少年 提交于 2019-12-03 21:04:34
I just asked a question on how to send data larger than the SendBufferSize and the answer was that is would be send in a couple of parts. My second question is how will this data be received? Will it be complete in the network stream or will it get it divided. the first question: Can you send a file larger that the SendBufferSize throuh a TcpClient? TCP is not a message only protocol. It is a stream based protocol and takes care of splitting the data for us. Lemme take you to the core section. There are two parts in the case of TCP - Segmentation and Fragmentation. Segmentation happens at TCP

Does TcpClient write method guarantees the data are delivered to server?

廉价感情. 提交于 2019-12-03 16:38:04
I have a separate thread on both client and server that are reading/writing data to/from a socket. I am using synchronous TcpClient im (as suggested in documention): https://msdn.microsoft.com/cs-cz/library/system.net.sockets.tcpclient%28v=vs.110%29.aspx When connection is closed .Read()/.Write() throws an exception. Does it mean that when .Write() method does not throw the data were delivered correctly to the other party or do I need to implement custom ACK logic ? I read documentation for both Socket and TcpClient class and none of them describe this case. All that a returning send() call

TcpListener: How can I detect a client disconnect?

和自甴很熟 提交于 2019-12-03 15:07:51
How can I detect when a client disconnects from the TcpListener ? Each of my clients is handled in a separate thread. Look at NetworkStream.Read , or depending on what you are using in your code maybe TCPClient.GetStream is more appropriate, but basically the same answer. From the docs: This method reads data into the buffer parameter and returns the number of bytes successfully read. If no data is available for reading, the Read method returns 0. The Read operation reads as much data as is available, up to the number of bytes specified by the size parameter. If the remote host shuts down the