| Because you need to listen to the socket and accept any connections. What you are doing is trying to connect to a remote socket. 
 Heres how it should look. The server now keeps going after the connection ends, so you can keep connecting.
 
 
Global TokenID:Int=$1257320,token:Int, stream:TStream
Print "Server"
Global server:TSocket = CreateTCPSocket ()
Local ok:Int = True
If Not BindSocket(server:TSocket,1234) Then Print "unable to bind port"; ok = false
If Not SocketListen(server) Then Print "unable to listen to socket"; ok = False
If ok then
	Print("Created Server.")
Else
	Print("Couldn't Create Server!")
	End
EndIf
While Not KeyDown(KEY_ESCAPE)
	Local client:TSocket = SocketAccept (server)
	If client Then
		stream = CreateSocketStream(client)
		token:Int=ReadInt(stream)
		Print token
		stream.Close()
	EndIf
Wend
CloseSocket(server)
End
 
 |