![]() |
TSockets
Hello, I am having a little trouble connecting a TSocket.
Each time I try I get this error. Script connection to http://wr3ckless.net:0 is not allowed, blocking. Maybe I am doing something wrong? My ultimate goal is to make the GServer listen on a host/port, in which it allows me to send data from a webserver to to GServer. Here is what I have experimented with. PHP Code:
|
|
Ok well I stuffed up a bit there.
But now that that's working; sending data via PHP on the other hand isn't. Here is my understanding of sockets. For the server: So first it creates a socket. Next it binds the socket to a port. Then it listens on the port. Then if data is sent it accepts it. For the client sending data: First it creates a socket. It then connects to the socket using the ip and port. It then can send data through the socket. Edit: I am getting this error in PHP Host lookup failed [-10003]: Unknown server error It also gives this error. unable to connect to 50.23.136.181:58860 (Connection refused) Here is my PHP code.. PHP Code:
I did however manage to get the GServer to echo data, but I had to connect to the ip and port using a socket testing program. My main goal is to have an input text box and a send button. |
Post your GScript code.
|
The GScript code is just echo's Bound to: ip : port waiting
And it works if I connect to it via a socket testing program, but via PHP it won't connect; it either gives connection refused or various other errors. When I get on my PC however I will post it. Additionally if it helps before I can get to my computer, to open a socket it uses your http_listensocket and http_socketconnect if I recall the names correctly. |
Here is the GS2..
PHP Code:
|
I'm having an issue with the socket still.
I am sending data to it via a HTML5 websocket. It is echoing what I believe to be the handshake and not the actual data being send. This is coming in when onReceiveData is triggered. GET / HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: 50.23.136.181:57248 Origin: http://wr3ckless.net Sec-WebSocket-Key: TTMGSf/g8hepQm7K1ZK6RA== Sec-WebSocket-Version: 13 Sec-WebSocket-Extensions: x-webkit-deflate-frame |
Did you look at the WebSocket protocol (RFC)? A quick read of the opening handshake indicates that you're going to have to reply with a 101 status code and a Sec-WebSocket-Accept header; see the RFC for how to get the value for that header.
Quote:
I don't know why you're using WebSockets for this anyway. You shouldn't need to talk from a browser -> the Graal server directly, so do it via some serverside language with regular old sockets. |
There is web-socket support in Graal but only for the Graal connection itself not for TSocket. It's pretty complex so some custom implementation is not recommended.
If you want to communicate with the Graal server it can be easier to use server-side communication (a php script or so) or just use http requests. |
I tried to use PHP but it kept giving connection refused errors as I don't know the configuration, eg weather it's UDP, TCP or what.
|
Quote:
|
I tried it with TCP and it just gave a connection refused error.
Could you happen to give me an example of one that successfully connects and sends some data? |
Quote:
|
That's a rather good idea. I shall give it a shot when I get home.
Atleast this way I should be able to see the responses. |
OK so I managed to connect to it via telnet.
Whatever I wrote was echo'd when I made it echo the data on onReceiveData. So my next step would to get this to work with PHP I suppose. |
All times are GMT +2. The time now is 12:31 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.