3 Replies - 750 Views - Last Post: 07 September 2009 - 10:17 AM Rate Topic: -----

#1 sirEgghead  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 24
  • Joined: 28-August 09

Server and Client on same PC

Posted 05 September 2009 - 05:58 PM

Howdy. I recently made a server and client in separate EXEs and I would like to run both on one PC. The server is listening on port 19357 and of course the client will connect via the same port. Of course this causes a conflict and an exception is thrown. I know it is possible to do this, I just don't know what I'm missing. For now I have a 'bandaid' on the problem by changing the port that the client connects through and forwarding the port through my router to the correct port. However I do not wish to use this as a permanent solution.

My server uses the following code to listen:
tlsClient = new TcpListener(19357);
tlsClient.Start();


My client uses the following code to connect:
tcpServer.Connect(strHost, 19357);


And of course my server is threaded to keep listening for incoming connections.

Any help at all on this would definitely be helpful.


Thanks,
Thomas

Is This A Good Question/Topic? 0
  • +

Replies To: Server and Client on same PC

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Server and Client on same PC

Posted 05 September 2009 - 06:01 PM

Try using 127.0.0.1, the call back, as the host string.
Was This Post Helpful? 1
  • +
  • -

#3 sirEgghead  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 24
  • Joined: 28-August 09

Re: Server and Client on same PC

Posted 05 September 2009 - 06:06 PM

Yeah that works. So it isn't possible to do this any other way?
Was This Post Helpful? 0
  • +
  • -

#4 sirEgghead  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 24
  • Joined: 28-August 09

Re: Server and Client on same PC

Posted 07 September 2009 - 10:17 AM

I know it is possible to listen for connections on a certain port and connect to that port on the same computer without having to use the callback because for one I am running Apache and I can connect to it with a web browser using my domain rather than 127.0.0.1.... It has to be possible with my own program. Does anyone know how I can accomplish this? 127.0.0.1 is all fine and dandy for testing purposes but I'd still like to be able to do this properly.


Thanks,
Thomas
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1