-1

I’m having trouble understanding some basic TCP/IP stuff.

I need to write a test app (client) that sends a message over TCP/IP to a server. The problem is I’m not writing the server, I have been given the message spec and IP address etc.

For testing purposes I would like to set up a test pc to be the server with configured IP address etc and see the message in wireshark on the server.

This this even possible?

I’m using c# and most examples tell me I need a server app set up at the other end. Doesn't the underlying protocol handle and accept the connection?

I'm using the TcpClient example code found at

https://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient(v=vs.110).aspx

Many Thanks

moonraker
  • 590
  • 7
  • 21
  • 1
    _"Doesn't the underlying protocol handle and accept the connection?"_ - can you explain your expectations a bit more clearly? Do you think you can connect to an arbitrary machine using an arbitrary port, and then just talk to that machine even if no process is listening? If you want to test this without connecting to the actual machine, you'll have to set up a server that at least mimics the protocol. – CodeCaster Feb 19 '16 at 16:06
  • @CodeCaster my bad for not reading the question well enough. – Glubus Feb 19 '16 at 16:08
  • If it is just for testing. You can use my working code (server-client): http://stackoverflow.com/questions/34586733/sending-a-value-from-server-to-client-with-sockets/34669446#34669446 things are also explained there – Ian Feb 19 '16 at 16:20
  • @Ian I'm afraid your answer there lacks any kind of explanation whatsoever, it's just a lot of boilerplate code that is required for communicating using asynchronous sockets in .NET anyway, and some text explaining which methods to call. I don't quite see how the OP here can work from that. – CodeCaster Feb 19 '16 at 16:27
  • @CodeCaster - i deleted my answer – Stan R. Feb 19 '16 at 16:45
  • @StanR I'm sorry if my comments prompted you to delete your answer. It wasn't necessarily incorrect, just in my opinion not complete enough for the OP, because it is unclear which part exactly they need help with. Let's wait for what they have to say about it. :) OP: what Stan basically said was that you could create a dummy server using [TcpListener](https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener(v=vs.110).aspx). But when you do, you still need to implement the application protocol ("the message spec") in order to have a meaningful exchange with your application. – CodeCaster Feb 19 '16 at 16:45
  • 1
    @CodeCaster - no worries, i do want to help OP, but you're right, i don't want to confuse them even more. OP needs to read on protocols first and then formulating a more practical question. – Stan R. Feb 19 '16 at 16:46

1 Answers1

0

Thank you for the replies.

I apologize, I was confusing a network connection with a tcp/ip connection. When I was connecting a pc I could see some exchange of messages and thought some tcp handshaking was going on there.

Now I know a bit more about the protocols I understand TCP is a separate protocol and requires its own connection.

Many thanks

moonraker
  • 590
  • 7
  • 21