Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Example Web Socket Networking

Zoo
Guest
Quote
2022-10-07 12:43:05

Hi....

This is the command to send data to TCP port using command line.

curl telnet://192.168.0.170:59403 <<< someText

This is the javascript code to execute this command

https://www.ambiera.com/coppercu...

This is an example of PHP to listen to the port on the server

https://stackoverflow.com/questi...

Congratulations you can now send data to a server using TCP which is what AAA systems use for networking.

Bye Bye


Zoo
Guest
Quote
2022-10-07 12:44:11

Where it says 'some Test' simply insert a javascript variable holding the data through string concatination...

Tutorial done!


okeoke
Registered User
Quote
2022-10-07 13:58:38

Hi Zoo,

This is not a websocket connection. I'm also on windows and don't have curl. How do I read the received data, though?


Zoo
Guest
Quote
2022-10-08 21:35:14

Curl is installed by default on all windows connections.

Websocket differs from TCP in that it enables a stream of messages instead of a stream of bytes...

Same protocol.


Zoo
Guest
Quote
2022-10-08 21:46:27

It also seems that TCP is faster then standard websockets because websockets share a port with https thus, there is typically more traffic on a websocket port, depending on your applications structure.


okeoke
Registered User
Quote
2022-10-08 22:38:20

Ok, but still how do you read the received data from coppercube game client?


Zoo
Guest
Quote
2022-10-09 12:48:03

Linked above


okeoke
Registered User
Quote
2022-10-09 16:38:14

No it's not.

Tcp is basically a two way data stream: one is incomming another one is outcomming. - can we agree on this statement?

So:
Firstly, you use system function to spawn a cmd process (which takes time), then it calls curl (which also takes time) and then you use telnet protocol (?) to send the data. After that the tcp connection gets closed, i.e. data stream from the host stops, since the cmd instance which holds it closes. Every time you call system function from the code these steps repeat again. I'm not sure if it's "faster" in any way even compared to the built-in http client.

Secondly, there is also an incomming stream. The question is how do I read it from the game? - curl runs inside the separate process and there is no ipc.

You haven't described this part, and without being able to read the data it doesn't make any sence to use this approach at all.


Aiming_bullets
Guest
Quote
2022-10-09 18:47:07

and he will never be able to explain it, cause he don't know. He can only link back to the other websites that has nothing to do with CC.
If you really want to check out curl and other multiplayer stuff than checkout @Ngame stuff, he has already used curl and other stuff to create a playable multiplayer game in coppercube. I am not sure if he is active anymore in the community.
or ask @sven, or @rolevix they also had created some multiplayar scripts


Zoo
Guest
Quote
2022-10-10 22:21:23

Hahahahahahahahahahahahahahahaha

TCP slower then http hahahahahahahahahahaha

aiming bullets...go away, you are a troll and not a programmer...

FYI - https also returns a response and is built o top of TCP as a second layer just like a web socket connection.

If you wanted a one way connection you would need to use UDP.


Zoo
Guest
Quote
2022-10-10 22:23:29

Hahahahahahaha TCP always returns a response. If you knew anything about TCP you would know that it is super simple to parse that response.

Buy I won't tell you how because you are a troll and not a real programmer


okeoke
Registered User
Quote
2022-10-11 09:43:55

@zoo

TCP doesn't return a response TCP is just a both ways data streams. Telnet might return a response, I dunno. It was introduced in like 70s, I'm not that old to catch up with this crap.

My question is not how do I parse the response, it is how do I get the byte/string/object/whatever data type response from cmd process there you run curl to coppercube process?. These are two different processes which do not share memory. There is actually no option for IPC in coppercube as I mentioned before.

To simplify my question: imagine, you have two instances of coppercube game running on the same machine, so there is no need for any networking now. How do you interchange data between them?

@Aiming_bullets
To tell the truth I'm just interested in what Zoo can propose.


Zoo
Guest
Quote
2022-10-11 14:31:35

LOL

https://www.freecodecamp.org/news/tcp-vs-udp/


Zoo
Guest
Quote
2022-10-11 14:32:50

Simple...

Use CMD command to save returned data to file and call data via javascript....

Really it is not hard...That is just one way of doing it


Zoo
Guest
Quote
2022-10-11 14:58:34

Another method is to do the same thing but via a batch script.

Also, CMD is technology older then the internet. It's origins are in dos which ran on 386 computers...

If you think that running a cmd call is slow, then you don't understand networking. Also TCP always returns a response because it is a handshacking service.

The data, however needs to be parsed on the other end and sent back manually

Furthermore...

TCP keeps the connection open at all times and always returns a response...running a bat script with TCP commands and within that bat script, writing the data to file is sufficient to keep that connection open and updating the io.

It is a simple method, that I have tested and it works.

Another method is to simply use CMD to make a direct connection to Mysql or other....

Mysql Uses TCP and it is not hard to insert the variables....


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact