-1

I tried the following example , it works perfectly in my LAN.

Chat Application Using Asynchronous TCP Sockets

Now, is there any possibility to do it online through the Internet?

NOTE: I have a free Webhosting Server (PHP). Or a WindowsServer with Internet Connection.

I've done some researches in google, but didn't found something helpful.

Robby Cornelissen
  • 91,784
  • 22
  • 134
  • 156

3 Answers3

1

It is possible, as long as you can provide a listening port on a non-private IP.

If you want to do this with PHP, you might want to think about a Server that is polled by the clients and backed by a database, as long running PHP processes tend to create more problems than they solve.

If your Windows server has an external IP or you have enough control over the routing/firewall/NAT you should be able to use the example you provided.

Izzy
  • 214
  • 4
  • 17
1

Tcp works just fine over the internet - however, it requires:

  • that the clients have access to each-other over TCP and some public IP address
  • that the ports required are open at all firewalls (in particular, inbound is likely to be blocked)

Neither of which is generally going to be the case. For internet purposes, in the context of "chat", you would typically have a central server acting as a hub, making it easy to satisfy both bullets.

If by "internet" you actually mean "web server", you might want to look into web-sockets (a duplex messaging protocol layered on top of TCP, negotiated initially via HTTP (before protocol-switching), and with good support in most browsers).

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Thank you sir, I have searched for Web-Sockets, I found [link](http://stackoverflow.com/questions/10200910/create-hello-wold-websocket-example) this one. Do you think, it will work for me? – StackUnderflow Jun 16 '14 at 08:24
  • @StackUnderflow to implement web-sockets correctly requires a *lot* more code than that (source: I wrote the web-socket server that we use here at stackoverflow); I would strongly recommend using a pre-existing library. Or for a framework that has fallback strategies, things like SignalR – Marc Gravell Jun 16 '14 at 08:31
0

For use it thought Internet, you have to configure your router for redirect the server port to your computer.

Akimoto
  • 368
  • 2
  • 11