Direkte Verbindung mit Netzwerk-Sockets
Netzwerk-Sockets sind Kommunikationsendpunkte in einem Computernetzwerk. Direkte Socket-Kommunikation betrifft Low-Level-Interaktionen mit dem Netzwerk und Internetverbindungen. Die Bedürfnisse der meisten Anwender werden zwar durch die Higher-Level-Web Operations abgedeckt, Raw Socket-Verbindungen sind jedoch auch eine Option.
Öffnen Sie ein Socket.
In[1]:=
![Click for copyable input](assets.de/connect-directly-to-network-sockets/In_10.png)
sock = SocketConnect[{"wolfram.com", 80}]
Out[1]=
![](assets.de/connect-directly-to-network-sockets/O_9.png)
Schreiben Sie eine Anfrage.
In[2]:=
![Click for copyable input](assets.de/connect-directly-to-network-sockets/In_11.png)
WriteString[sock, "GET /index.php HTTP/1.0 \n\n"]
Lesen Sie die Antwort.
In[3]:=
![Click for copyable input](assets.de/connect-directly-to-network-sockets/In_12.png)
StringTake[ReadString[sock], 200]
Out[3]=
![](assets.de/connect-directly-to-network-sockets/O_10.png)
Schließen Sie das Socket.
In[4]:=
![Click for copyable input](assets.de/connect-directly-to-network-sockets/In_13.png)
Close[sock]
Out[4]=
![](assets.de/connect-directly-to-network-sockets/O_11.png)