Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
14
Task/Sockets/Ada/sockets.adb
Normal file
14
Task/Sockets/Ada/sockets.adb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
with GNAT.Sockets; use GNAT.Sockets;
|
||||
|
||||
procedure Socket_Send is
|
||||
Client : Socket_Type;
|
||||
begin
|
||||
Initialize;
|
||||
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;
|
||||
7
Task/Sockets/AutoIt/sockets.au3
Normal file
7
Task/Sockets/AutoIt/sockets.au3
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Func _HelloWorldSocket()
|
||||
TCPStartup()
|
||||
$Socket = TCPConnect("127.0.0.1", 256)
|
||||
TCPSend($Socket, "Hello World")
|
||||
TCPCloseSocket($Socket)
|
||||
TCPShutdown()
|
||||
EndFunc
|
||||
38
Task/Sockets/C/sockets-1.c
Normal file
38
Task/Sockets/C/sockets-1.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *msg = "hello socket world";
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, sock, len, slen;
|
||||
|
||||
struct addrinfo hints, *addrs;
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (0 == getaddrinfo("localhost", "256", &hints, &addrs))
|
||||
{
|
||||
sock = socket(addrs->ai_family, addrs->ai_socktype, addrs->ai_protocol);
|
||||
if ( sock >= 0 )
|
||||
{
|
||||
if ( connect(sock, addrs->ai_addr, addrs->ai_addrlen) >= 0 )
|
||||
{
|
||||
const char *pm = msg;
|
||||
do
|
||||
{
|
||||
len = strlen(pm);
|
||||
slen = send(sock, pm, len, 0);
|
||||
pm += slen;
|
||||
} while ((0 <= slen) && (slen < len));
|
||||
}
|
||||
close(sock);
|
||||
}
|
||||
freeaddrinfo(addrs);
|
||||
}
|
||||
}
|
||||
26
Task/Sockets/C/sockets-2.c
Normal file
26
Task/Sockets/C/sockets-2.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <winsock2.h>
|
||||
#include <assert.h>
|
||||
|
||||
// link winsock (MSVC extension. Ignored by MinGW)
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
|
||||
const char MESSAGE[] = "hello socket world";
|
||||
|
||||
int main() {
|
||||
WSADATA wsa;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsa);
|
||||
SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
struct sockaddr_in server = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_port = htons(256),
|
||||
.sin_addr.s_addr = inet_addr("127.0.0.1")
|
||||
};
|
||||
|
||||
assert(connect(s, (struct sockaddr *)&server, sizeof(server)) == 0);
|
||||
send(s, MESSAGE, sizeof(MESSAGE) / sizeof(char), 0);
|
||||
|
||||
closesocket(s);
|
||||
WSACleanup();
|
||||
return 0;
|
||||
}
|
||||
5
Task/Sockets/Emacs-Lisp/sockets.el
Normal file
5
Task/Sockets/Emacs-Lisp/sockets.el
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(let ((proc (make-network-process :name "my sock"
|
||||
:host 'local ;; or hostname string
|
||||
:service 256)))
|
||||
(process-send-string proc "hello socket world")
|
||||
(delete-process proc))
|
||||
8
Task/Sockets/F-Sharp/sockets.fs
Normal file
8
Task/Sockets/F-Sharp/sockets.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
open System.Text
|
||||
open System.Net.Sockets
|
||||
|
||||
let sock =
|
||||
new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
|
||||
sock.Connect("127.0.0.1", 256)
|
||||
sock.Send(Encoding.UTF8.GetBytes "hello socket world")
|
||||
sock.Close
|
||||
14
Task/Sockets/Odin/sockets.odin
Normal file
14
Task/Sockets/Odin/sockets.odin
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:net"
|
||||
|
||||
MSG: string : "hello socket world"
|
||||
|
||||
main :: proc() {
|
||||
sock, err := net.dial_tcp("127.0.0.1:256")
|
||||
if err != nil do fmt.panicf("Connection failed: %v", err)
|
||||
|
||||
_, err = net.send(sock, transmute([]u8)MSG)
|
||||
if err != nil do fmt.panicf("Error sending: %v", err)
|
||||
}
|
||||
9
Task/Sockets/Pluto/sockets.pluto
Normal file
9
Task/Sockets/Pluto/sockets.pluto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
local socket = require "pluto:socket"
|
||||
local host, port, transport = "localhost", 256, "udp"
|
||||
local s = socket.connect(host, port, transport)
|
||||
if s then
|
||||
s:send("hello socket world")
|
||||
s:close()
|
||||
else
|
||||
print($"Unable to connect to '{host}' on port: {port} using {transport}")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue