I have an unusual question that I hope to get input on. I'm new to network programming and am learning socket programming via the .NET "TcpListener" and "TcpClient" classes in the System.Net.Sockets namespace. I need to use them in an unusual manner though: I need to be able to establish a connection between computer A and computer B. Computer A will be running an instance of the "TcpClient" class and will attempt to open a connection to computer B which is running an instance of "TcpListener". This part seems straight forward. However, once the connection has been established I need to reverse the roles so that computer A becomes the machine that waits for and responds to messages sent from computer B. In other words computer A then becomes the server and computer B becomes the client. This role reversal must use the same connection that was opened by computer A when it was initially acting as a client. It's not clear to me how to do this as all the examples and the (excellent) book "TCP/IP Sockets in C#" I'm reading always use these classes in their predefined roles. Is there actually a way to do this? Do I have to drop down to the "Socket" class rather than use the more abstracted "TcpListener/TcpClient" classes?
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in SOCKETS
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- My server TCP doesn't receive messages from the client in C
- how is strncpy able to copy from source to empty destination?
- Python Multicast packet receiver stops receiving multicast packets when computer is connected to WiFi
- Python Client-Server Communication with Protocol
- Reversed TLS re-connection issue
- Android 13 & 14 seem to close WebSocket connection, if i put app in background, after ~20s
- Java SocketException: Connection reset,. What is the cause?
- Multipart/form-data with chunked data transfer (ICAP protocol)
- View Socket View
- Client connection timeout during Android & Windows PC communication via sockets
- Browser connect to raw sockets even possible?
- Protocol 43200 after unpacking received data
- Unity SocketIo using Best http2 plugin want to use in webgl
- How does pre-allocating a pool of SocketAsyncEventArgs objects upfront improve the performance of a server application in c#
Related Questions in TCPCLIENT
- TCP Client Losing Connection When Writing Data
- Java TCP socket want to multiple times input with one connection
- Getting error while using the MessagePattern to communicate between microservices
- Read multiple sockets from single thread [low-latency]
- Sockets Connector - is there any way to read data instead of send and receive - Mule 4
- .NET 8 C#: SslStream "Cannot determine the frame size or a corrupted frame was received."
- TCP connection only sending but not receiving messages
- boost asio tcp connection no received data after reconnecting and reading
- The operation is not allowed on non-connected sockets. System.Net.Sockets
- How get real raw data over tcp nodejs
- How get real raw data over tcp
- How TCP Server keeping NetworkStreams of each connecting client with corresponding sockets (Fleck Code reference )
- How to host .net tcpclient listner in azure virtual machine
- Recive [Errno 111] Connection refused on load test for TCP Server
- Tcp Connection - React Native Windows
Related Questions in TCPLISTENER
- TCP Client Losing Connection When Writing Data
- The operation is not allowed on non-connected sockets. System.Net.Sockets
- TCP Listener Reading date from client but after some time it stuck
- Making an async server in C# but StartAsync() giving me issues
- Didn't receive the full message in TCP server-client
- Can I convert from socket2::Socket to Tokio::net::TcpStream?
- How to resolve Error: connect EISCONN ::1:5555 - Local (:ffff.127.0.0.1:5555)
- Testing TCPstream reading function
- SimpleHttpServer and the Titanium.Web.Proxy
- TcpListener receives file in chunks from Tcp Client
- C# Winforms | I can't get values from Form in new class
- GUI Multi Thread TCP Server-Client - GUI crash when starting listener
- tcplistener/tcpclient await is stopping code after from running
- How to make NUnit test wait for thread to complete?
- Getting "Invalid port value" with TcpListener
Related Questions in SYSTEM.NET.SOCKETS
- Problem with sending file via socket in Base64
- SocketException when using NpgsqlConnection
- How to create new ServerSocket C#
- Clear net.socket of any data
- Breaking a big class into smaller methods
- How to achieve a "peer-to-peer" connection with TCPClient/TCPListener in System.Net.Sockets C# (NAT Traversal, no portforward, hole punching)
- Is there a way to get tcp server to send responses other than echoing incoming messages?
- Delay when displaying a message received by a Telnet client
- C# Windows form application freezing when created
- Making net.Socket connection to remote port in a node API endpoint
- Occasional drop of connection with Socket exception 0x80004005
- Unable to find the reference to code example on microsoft docs
- Will UDP packets merge on receive?
- How to make different users connect to the same socket?
- Non-firing quartz-scheduler job
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)