FANDOM


16px-Pencil

C Edit

This article is missing a code example in the C language.

C Sharp Edit

using System;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace TCPServerTutorial
{
   class Server
   {
      private TcpListener tcpListener;

      public Server()
      {
         this.tcpListener = new TcpListener(IPAddress.Any, 3000);
         ListenForClients(); // Method for listening
      }
   }
}

Java Edit

This article is missing a code example in the Java language.

Pascal Edit

This article is missing a code example in the Pascal language. (FreePascal and other implementations)

Tcl Edit

Tcl provides a very simple scheme for event-oriented processing of stream data using the socket, fconfigure and fileevent commands.

Here is a simple implementation of an RFC 867 DAYTIME service

proc Daytime {channel client_address client_port} {
    puts $channel [clock format [clock seconds]]
    close $channel
}
socket -server Daytime 13
vwait forever

The socket command specifies a Tcl command to be run when a client connects and the port to listen on. Each time a client connects to the service the command is executed with three arguments provided by Tcl. The first is a Tcl channel for communicating with this client and the remaining arguments are the client address and port. The final vwait command causes the above script to wait forever processing events. Note that forever is not some magic argument, just a variable that will never be set in the above script. Java Applets

In Tcl 8.5 the apply command permits the use of lambda expressions so the above can be rendered as

socket -server {apply {{c a p} {puts $c [clock format [clock seconds]];close $c}}} 13
vwait forever

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.