Close socket/port connection from different process [duplicate] - c#

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to get a specific socket and close it
I want to know a way to close an existing socket connection from a different process (In Windows). I don't have handle to the socket, I only know the port number. I think I may need to write kernel level code to do this. Any references in C#, or C++?

There are many ways to do that.
One of them is to inject a dll into the target process which will wait, for a packet or an other signal, to be sent by your main process and then close the socket.
Or you could just send a packet to the already open socket that will trigger an exception and therefore the deletion of the socket but I doubt that's going to be any easier than injecting a DLL.
Or maybe you could send a FIN signal to the open socket.

Related

Where is my understanding of Socket.Send wrong? [duplicate]

This question already has answers here:
Does TcpClient write method guarantees the data are delivered to server?
(5 answers)
Can I free my data immediately after send() in blocking mode?
(2 answers)
what happens when I write data to a blocking socket, faster than the other side reads?
(2 answers)
Closed 2 years ago.
I created this proof of concept code to exercise my understanding of how Socket.Send behaves.
The host im pointing to is actually on Australia Central azure datacenter (and im in Brazil, so its half-world distance) and yet the avg TICK is between 40 and 70. And im not talking milliseconds, TICKS!
Can anyone explain to me what is going on?
I was expecting to have the avg milliseconds close to 200 or something... but right now its not even close to 1ms!
From the docs:
[...] A successful completion of the Send method means that the underlying system has had room to buffer your data for a network send.
So there's no guarantee that the data has actually reached the destination once the Send method returns.

Is it possible to drop a tcp connection and not receive a notification/exception [duplicate]

This question already has answers here:
Is TCP 100% reliable? [closed]
(3 answers)
How reliable is a TCP connection?
(2 answers)
How reliable is .NET TCP protocol?
(5 answers)
Closed 5 years ago.
I'm currently working with the assumption that when sending TCP data with System.Net.Sockets.Socket.Send ,I am guaranteed to get an exception if the connection drops. Is it possible to have a connection drop at the OS layer without receiving a notification/exception in the C# application on top?
I don't imagine there is such a case, in .net, but how would I go about demonstrating this to someone that is skeptical.
Actually as far as i know It is possible. Imagine you create a packet send it and it gets dropped by the way. Os should automatically retransmit when ttl timesout. It will retry few times before giving up. More advanced firewalls have one small option as I remember. Drop with or without notification. Second looks like packet was 'lost' on the way to destination. They actually receive it but let's say- sends them to null without any answer.
I do not know how exactly socket.send works but from network point of view it is possible to not get confirmation for every packet that was lost/dropped.

How do I open a TCPClient with a given source port? [duplicate]

This question already has an answer here:
Is there a way to specify the local port to used in tcpClient?
(1 answer)
Closed 9 years ago.
First off, I don't want to do this in production! I need to test whether someone else's implementation of a protocol on top of TCP is causing issues.
I want to use a certain outbound port over and over for multiple TCP sessions. Windows normally increments the port for each new session, and I want to circumvent this for testing. How can I set the outbound port of a TcpClient?
According to another post (Is there a way to specify the local port to used in tcpClient?). You need to use the constructor overload that takes an IPEndpoint in order to specify the local port to use.

Creating virtual serial port with C# [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Faking an RS232 Serial Port
I have an application that reads data from serial port. To test the application i would like to create a virtual serial port that generates data and puts the the port at the same PC, so that the other app can access that data.
Any idea how?
Thanks
I have used com0com tool for this. It has no direct API, but you can write an application (or a method) which starts a new com0com process to set up / modify your virtual ports "on the fly" with commandline parameters.

Send and receive UDP data [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Sending UDP Packet in C#
I have some data in hex format that I would like to send to a UDP server and then get a response back from the server that contains some data. How would I go about doing this in C#?
I might add that I do not have local access to the server, I would just like to see which response I get by sending this particular data to it.
1- A Chat Application Using Asynchronous UDP sockets
2- Send UDP packet in C#
3- Testing TCP and UDP socket servers using C# and .NET
4- Receive and send data
5- UDP Send and Receive using threads in VB.NET
6- A UDP based Reliable Data Transfer Library
7- msdn microsoft

Categories