Client/Server - which target/which module?
Monkey Forums/Monkey Beginners/Client/Server - which target/which module?
| ||
Hey monkeys! I have my TCPserver that runs on my windows (written with blitzPlus) Now I want my android/iphone to connect to it, not just other windows' (Desktop target communicates with my server perfectly) Which module does utilize theese functions? Is there an example of how to use internet access to connect to my server via TCP? I mean from what I understand only desktop and stdcpp targets have this. What about UDP? Do I have to migrate to UDP protocols to get it working? Additional: It goes like this: -I create a socket class -I connect it to my server -It works fine -But only with desktop ( |
| ||
TCP works for almost all targets: http://www.monkey-x.com/Community/posts.php?topic=7698 |
| ||
Import monkey Import os Import mojo Import brl Global Client:TcpStream Class Exec Extends App Method OnCreate() SetUpdateRate(30) Client = New TcpStream() Client.Connect(IP ADRESS HERE,41337) If Client Print "Connected!" Else Print "Failure!" Endif End Method Method OnUpdate() If KeyHit(KEY_BACK) Then ExitApp(1) End Method Method OnRender() Cls() End Method End Class Function Main:Int() ; New Exec ; Return 0 ; End Function This only works for desktop. Other targets return "Native os module not implemented". I'll look for an answer in your link but it would be great to understand the nature of a problem ) UPD: It does the same thing with that code in that link. Desktop only |
| ||
StoneFaceEXE wrote: Other targets return "Native os module not implemented". Don't use OS module. |
| ||
Oh hey! It worked. Well that was silly of me, that was really obvious. Shame that it doesn't work with html5, that would speed up the debug process. Thank you everyone! |
| ||
You may create new communication class based on WebSocket to debug purposes or even for release. Some Http(s)/SPDY servers are enough fast now for many tasks. And easy to implementation and debug. |
| ||
That sounds too advanced for me) BTW: If I TCP_Stream.Connect("ipadress",port) it returns true, even though the server is down - is that a normal behaviour? |
| ||
StoneFaceEXE wrote: TCP_Stream.Connect("ipadress",port) it returns true, even though the server is down - is that a normal behaviour? It's not normal. What is target it happens? Try async method to connection. |
| ||
I'm so silly, I checked if client connected withIf TCP_Stream then Print "Connected" Obviously, with TCP_Stream being a new instance of TcpStream class it always returned True since I called New() construction on it. So I changed it to If TCP_Stream.Connect("ip",port) then Print "Connected" And now it is idetified correctly. I wonder though why doesn't... If TCP_Stream.IsConnected then Print "Connected" ...why can't I access IsConnected, since TcpStream class extends Socket class. Shouldn't it inherit Socket's properties? This goes to TCP_Stream.ConnectAsync as well. I can't access socket methods( |
| ||
StoneFaceEXE wrote: Shouldn't it inherit Socket's properties? It should. Look to source generated monkey for your target. |
| ||
Dang. I'm no good with native sources ( |
| ||
Oh wait. TcpStream extends stream, not socket. UPD: Gah, it's so confusing( |
| ||
StoneFaceEXE wrote: TcpStream extends stream, not socket. Anyway you haven't access to private field. But it is not hard task to create a new class with public socket field. |