Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changes between Version 10 and Version 11 of TutInternetConnectivity

Show
Ignore:
Author:
larsivi (IP: 84.48.63.70)
Timestamp:
08/26/09 18:50:48 (5 years ago)
Comment:

Some adjustments

Legend:

Unmodified
Added
Removed
Modified
  • TutInternetConnectivity

    v10 v11  
    1 [wiki:TutInternetConnectivityComments Leave Comments, Critiques, and Suggestions Here] 
    2  
    31= Internet Connectivity Tutorial = 
    42 
    5 Tango provides classes for performing with multiple types of socket activities. The basic types of activities include connected socket communications, connectionless socket communications, and multicast socket communications. 
     3Tango provides classes for performing multiple types of socket activities. The basic types of activities include connected socket communications, connectionless socket communications, and multicast socket communications. 
    64 
    7 Connected communications require one side to open a port and the other side to connect to it. 
    8 In Tango these two functionalities are in two separate classes. 
    9 Both of these classes inheret from the [http://tango.dsource.org/docs/current/tango.net.Socket.html Socket] class. 
     5Connected communications require one side to open a port and the other side to connect to it. In Tango these two functionalities are in two separate classes, both inhereting from the [http://tango.dsource.org/docs/current/tango.net.Socket.html Socket] class. 
    106 
    117== Tcp Server == 
    12 The [http://tango.dsource.org/docs/current/tango.net.ServerSocket.html ServerSocket] class implements the functionality needed to open a socket to inbound connections. 
    13 Open a tcp/ip socket with tango is very easy, all you have to do is to import 
     8The [http://tango.dsource.org/docs/current/tango.net.ServerSocket.html ServerSocket] class implements the functionality needed to open a socket for inbound connections. 
     9Opening a TCP/IP socket using Tango is very easy, all you have to do is to import 
    1410 
    1511{{{ 
     12#!d 
    1613import tango.net.device.Socket; 
    1714import tango.net.InternetAddress; 
    1815}}} 
    1916 
    20 The first one imports the ServerSocket class, the second one imports the class to generate a tcp/ip internet address. 
    21 To create you can do the following: 
     17The first one imports the !ServerSocket class, the second one imports the class to generate a TCP/IP Internet address. 
     18To use you can do the following: 
    2219 
    2320{{{ 
     21#!d 
    2422//create a tcp/ip server on port 1234 tcp 
    2523auto server = new ServerSocket(new InternetAddress("localhost", 1234)); 
    3634 
    3735The [http://tango.dsource.org/docs/current/tango.net.Socket.html Socket] class implements the functionality needed to connect to an open socket. 
    38 As with ServerSocket, using socket is very easy, just import: 
     36As with !ServerSocket, using socket is very easy, just import: 
    3937 
    4038{{{ 
     39#!d 
    4140import tango.net.device.Socket; 
    4241import tango.net.InternetAddress; 
    4342}}} 
    4443 
    45 The first line import the Socket class which we are going to use, the second one imports the class to generate a valid tcp/ip address. To connect to a server you can do the following: 
     44The first line import the Socket class which we are going to use, the second one imports the class to generate a valid TCP/IP address. To connect to a server you can do the following: 
    4645 
    4746{{{ 
     47#!d 
    4848auto s = new Socket();   
    4949 
    5757s.write(command); 
    5858 
    59 //crate a buffer and an int variable to store received data and bytes received 
     59//create a buffer and an int variable to store received data and bytes received 
    6060char[1024] buf; 
    6161int bytes; 
    6666//display received data 
    6767Stdout("Received: ", buf[0..bytes]).newline; 
    68  
    6968}}} 
    7069 
    7170== Client and Server all together == 
    7271 
    73 In [http://www.dsource.org/projects/tango/browser/trunk/example/networking/socketserver.d tango there is an example file] showing all the needed steps for a client + server application This is the file 
     72In [http://www.dsource.org/projects/tango/browser/trunk/example/networking/socketserver.d Tango there is an example file] showing all the needed steps for a client + server application, such as the following example: 
    7473 
    7574{{{ 
     75#!d 
    7676/******************************************************************************* 
    7777 
    129129}}} 
    130130 
    131 Connectionless socket communications are preformed with the [http://tango.dsource.org/docs/current/tango.net.DatagramSocket.html DatagramConduit] class. 
     131Connectionless socket communications are performed with the [http://tango.dsource.org/docs/current/tango.net.DatagramSocket.html DatagramConduit] class. 
    132132 
    133 Multicast socket communications are preformed with the [http://tango.dsource.org/docs/current/tango.net.MulticastSocket.html MulticastSocket] class. 
     133Multicast socket communications are performed with the [http://tango.dsource.org/docs/current/tango.net.MulticastSocket.html MulticastSocket] class.