AlmarM Posted November 9, 2009 Share Posted November 9, 2009 (edited) Hi,I found this TCP UDF made by Kip, and I would like to know how to send a file (like a screenshot) via TCP.Also, I tried to start making the server. But I have no idea how this stuff works, this is my first time using TCP. Could anyone make a basic server example? Much appreciated.AlmarMRead next post. Edited November 9, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
AlmarM Posted November 9, 2009 Author Share Posted November 9, 2009 (edited) I kind of managed to make a server with 2 clients, now what I would love to know, how to send a string (for example: Hai!) to the other connected client?Server#include "TCP.au3" $hServer = _TCP_Server_Create(1337, @IPAddress1) ToolTip("SERVER: Server Created.", 0, 0) _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient") _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect") While 1 WEnd Func NewClient($hSocket, $iError) ToolTip("SERVER: Client connected.", 0, 0) EndFunc Func Disconnect($hSocket, $iError) ToolTip("SERVER: Client disconnected.", 0, 0) EndFuncClient 1#include "TCP.au3" $hClient = _TCP_Client_Create(@IPAddress1, 1337) ToolTip("CLIENT1: Connected.", 0, 30) _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received") _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected") While 1 WEnd Func Received($hSocket, $sReceived, $iError) ToolTip("CLIENT1: Received: " & $sReceived, 0, 60) EndFunc Func Disconnect($hSocket, $iError) EndFuncClient 2#include "TCP.au3" $hClient = _TCP_Client_Create(@IPAddress1, 1337) ToolTip("CLIENT2: Connected.", 0, 60) _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received") _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected") While 1 WEnd Func Received($hSocket, $sReceived, $iError) ToolTip("CLIENT2: Received: " & $sReceived, 0, 60) EndFunc Func Disconnect($hSocket, $iError) EndFuncAlmarM Edited November 9, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
CodyBarrett Posted November 9, 2009 Share Posted November 9, 2009 personaly i'm not familiar with Kip's UDF... though... TCPSend ($Socket,$Data) will send it.. and TCPRecv ($Socket,$MaxLen) Kip's UDF simplifies it ALOT, but if you want to learn, i have TCP examples in my Sig, using Multiclient method WITHOUT kip's UDF... [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
AlmarM Posted November 9, 2009 Author Share Posted November 9, 2009 (edited) Yeah, but I want to know how to send a string from Client 1 to Client 2, im totally new to this O_O EDIT: My 1,000th post, Edited November 9, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
AlmarM Posted November 9, 2009 Author Share Posted November 9, 2009 (edited) *tries to bump* Noone knows how to send a string like "hello" from a connected client to another connected client? Edited November 9, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
darkjohn20 Posted November 9, 2009 Share Posted November 9, 2009 Use Cody's advice and look at his examples. He has a multi-client chat program that allows clients to talk to each other. By the way, thanks Cody on this same issue a while back. Link to comment Share on other sites More sharing options...
CodyBarrett Posted November 10, 2009 Share Posted November 10, 2009 (edited) Almar... i will take a look through TCP.au3 and try to figure it out and give an example of how.Edit:well.Use _TCP_RegisterEvent() to register an event. These are the possible events to register:$TCP_SEND - When you send something.$TCP_RECEIVE - If something is received.$TCP_CONNECT - When you connect to the server. (Client only)$TCP_DISCONNECT - When a connection is closed.$TCP_NEWCLIENT - When a new client connects to the server. (Server only)now, im not positive but this may be what your looking for _TCP_Server_Create($iPort, $sIP="0.0.0.0") _TCP_Server_Broadcast($sData) _TCP_Server_ClientList() _TCP_Server_ClientIP($hSocket) _TCP_Server_DisconnectClient($hSocket) _TCP_Server_Stop() _TCP_Client_Create($sIP , $iPort) _TCP_Client_Stop($hSocket) _TCP_Send($hSocket, $sText) ;to send!! _TCP_RegisterEvent($hSocket, $iEvent, $sFunction);make a function when there is Data being recieved. Edited November 10, 2009 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
AlmarM Posted November 10, 2009 Author Share Posted November 10, 2009 Almar... i will take a look through TCP.au3 and try to figure it out and give an example of how.Edit:well.now, im not positive but this may be what your looking for _TCP_Server_Create($iPort, $sIP="0.0.0.0") _TCP_Server_Broadcast($sData) _TCP_Server_ClientList() _TCP_Server_ClientIP($hSocket) _TCP_Server_DisconnectClient($hSocket) _TCP_Server_Stop() _TCP_Client_Create($sIP , $iPort) _TCP_Client_Stop($hSocket) _TCP_Send($hSocket, $sText) ;to send!! _TCP_RegisterEvent($hSocket, $iEvent, $sFunction);make a function when there is Data being recieved.Aah, I think I've got it. First Client1 (or 2, w/e) sends data to the server, then when it comes to the server, it broadcasts it and then send it to Client 2.I'll play some with this, ill let you guys when im having a problem. Thanks! Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
CodyBarrett Posted November 11, 2009 Share Posted November 11, 2009 no problemo [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now