2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1 +1,4 @@
For this exercise a program is open a socket to localhost on port 256 and send the message "hello socket world" before closing the socket. Catching any exceptions or errors is not required.
For this exercise a program is open a socket to localhost on port 256 and send the message "hello socket world" before closing the socket.
Catching any exceptions or errors is not required.
<br><br>

View file

@ -1,20 +1,14 @@
with GNAT.Sockets; use GNAT.Sockets;
procedure SocketSend is
procedure sendData (IP : String; Msg : String) is
Client : Socket_Type;
Address : Sock_Addr_Type;
Channel : Stream_Access;
begin
Create_Socket (Client);
Address.Addr := Inet_Addr(ip);
Address.Port := 256;
Connect_Socket (Client, Address);
Channel := Stream (Client);
String'Write (Channel, Msg);
Close_Socket (Client);
end;
procedure Socket_Send is
Client : Socket_Type;
begin
Initialize;
sendData ("127.0.0.1","hello socket world");
end;
Create_Socket (Socket => Client);
Connect_Socket (Socket => Client,
Server => (Family => Family_Inet,
Addr => Inet_Addr ("127.0.0.1"),
Port => 256));
String'Write (Stream (Client), "hello socket world");
Close_Socket (Client);
end Socket_Send;

View file

@ -6,8 +6,10 @@ version(Win32) {
pragma(lib, "ws2_32.lib") ;
}
void main() {
long res;
auto socket = new Socket(AddressFamily.INET, SocketType.STREAM) ;
socket.connect(new InternetAddress("localhost",256)) ;
writefln(socket.send(cast(void[])"hello socket world"), " bytes sent.") ;
res = socket.send(cast(void[])"hello socket world") ;
writefln("Socket %d bytes sent.", res) ;
socket.close() ;
}

View file

@ -0,0 +1,10 @@
defmodule Sockets do
require Logger
def send_message(port, message) do
{:ok, socket} = :gen_tcp.connect('localhost', port, [])
:gen_tcp.send(socket, message)
end
end
Sockets.send_message(256, "hello socket world")

View file

@ -0,0 +1,4 @@
(set 'socket (net-connect "localhost" 256))
(net-send socket "hello socket world")
(net-close socket)
(exit)

View file

@ -2,5 +2,5 @@ my $host = '127.0.0.1';
my $port = 256;
my $client = IO::Socket::INET.new(:$host, :$port);
$client.send( 'hello socket world' );
$client.print( 'hello socket world' );
$client.close;

View file

@ -0,0 +1,4 @@
(let* ((server (first (getaddrinfo "localhost" 256)))
(sock (open-socket server.family sock-stream)))
(sock-connect sock server)
(put-string "hello socket world"))