Jump to content

Error with TCP chat


CodyBarrett
 Share

Recommended Posts

well its not really an error but when i run exe OR au3 of server THEN client like im supposed to, nothing happens (nothing TCP related) what could i change here? ill UPLOAD the server+client files instead of posting the scripts BECUASE its slightly long.

Link to comment
Share on other sites

.. I Took The Time To Rewrite A TCP Chat.. Its Easy To Read And Works Well... I Worked Really Hard On It And I Hope It Helps ^^;

Download Information :

Name : TCP Chat.zip

File Type : .Zip

File Contents :

[1] = Client.Au3

[2] = Client.Ini

[3] = Server.Au3

[4] = Server.Ini

Hosted On : Media Fire

Size : 2.89 KB

Link : http://www.mediafire.com/download.php?mjn4nzmx5bb

** I Really Hope This Helps ^^! **

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

thanks, although i would like to learn what im doing wrong, or maybe how to do one on my own.

EDIT

alright, would you mind if i "disected" your script and make it my own(personal use, between me N a friend) that would help me learn lol

Edited by bob00037
Link to comment
Share on other sites

lol, some people are picky about who uses what andd for what for, i assumed lol sorry thanks lol BTW this is probably my 2nd or 3rd day learning TCP

EDIT

aww lol good thing you took so much time withthis its so good! does it only do lan? cause i changed the .ini to lan=false... yet i cant test it ATM, also how would you send a displaypicture? convert into binary? ftp download it directly from your comp? i have so many questions

Edited by bob00037
Link to comment
Share on other sites

I'm Not Really Good With.. That But I'd Suggest Maybe.. Build In HTML?.. Like Uploading The File To A Site.. And Sending The HTML To The Client And Then The Client Executes It.. As A Display Pic.. { Just A Ideal } Also.. If You'd Like I Can Port Forward And We Can Chat Over The Internet :) Also If You Got An Msn Add Me : Pk4fun@Live.com ^^;

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

well, FTP isnt that just your ip, port and the directory of your computer, cause on FTP servers(i have a few im pretty sure) you can sign in anonymisly, thats what downloading ANYTHING pretty much is. idk thats just what i think, PS TCP does that work over dialup?

Link to comment
Share on other sites

good point, but to HOST a TCP server (as john has kindly pointed out) you need a private server with a static ip thanks john.

Edited by bob00037
Link to comment
Share on other sites

when i did this script

#Include <GUIConstantsEx.Au3>
#Include <WindowsConstants.Au3>
#Include <EditConstants.Au3>
#Include <StaticConstants.Au3>
#Include <Misc.Au3> 
#Include <GUIEdit.Au3>
#Include <Date.Au3>

Opt ('GUIOnEventMode','1')

TCPStartup()

Global $Ip = IniRead('Server_On_Load.ini','#Server', 'Ip','')
If IniRead('Server_On_Load.ini','#Server','LAN','') = 'True' Then $Ip = @IPAddress1
Global $Port = IniRead('Server_On_Load.ini','#Server','Port','')
Global $S_Name = IniRead('Server_On_Load.ini','#Server','Username','')
Global $Con_Sock = '-1'
Global $Listen = TCPListen($Ip , $Port,'10')

If $Listen = ('-1') Then Exit MsgBox ('16','Error Code 01','Cannot Start Server On IP : ' & $IP & ', Port : ' & $Port , '0')
    
$Gui = GUICreate('Server =' & $Ip & '- On - ' & $Port,'400','400','-1','-1','-1',BitOR(128,$WS_EX_TOPMOST))

$Menu = GUICtrlCreateMenu('File')
$Exit = GUICtrlCreateMenuItem('Exit',$Menu)
$Font = ('Roman')
$F_Color = ('0x00FF00')
$M_Bck_Grnd = ('0x000000')
$S_Bck_Grnd = ('0x000000')
$Change = GUICtrlCreateMenu('Change')
$Ch_Font = GUICtrlCreateMenuItem('Font',$Change)
$Ch_FontC = GUICtrlCreateMenuItem('Font Color',$Change)
$Ch_G = GUICtrlCreateMenuItem('Gui Color',$Change)
$CH_M = GUICtrlCreateMenuItem('Main Window Color',$Change)
$CH_S = guictrlcreatemenuitem('Send Window Color',$Change)

$Input = GUICtrlCreateInput($S_Name,'200','0','100','20','1')
GUICtrlSetFont($Input,8,'','',$Font)
$Main = GUICtrlCreateEdit('','5','30','395','230','2103360')
GUICtrlSetFont($Main,'10','','',$Font)
GUICtrlSetColor($Main,$F_Color)
GUICtrlSetBkColor($Main,$M_Bck_Grnd)
$Send = GUICtrlCreateEdit('','5','270','395','110')
GUICtrlSetColor($Send,$F_Color)
GUICtrlSetBkColor($Send,$S_Bck_Grnd)
GUICtrlSetState($Send,$GUI_FOCUS)
GUISetState(@SW_Show,$GUI)

_Main_Log ('[ ' & _NowTime () & '] Loading...')
_Main_Log ('[ ' & _NowTime () & '] Ip :' & $Ip & ' - Port : ' & $Port)
_Main_Log ('[ ' & _NowTime () & '] UserName =' & $S_Name)
_Main_Log ('[ ' & _NowTime () & '] Starting, Waiting For Client(s) To Connect...')

_Accept_Connection()

while 1
$M = GUIGetMsg()
If $M = $GUI_EVENT_CLOSE Then 
    TCPShutdown()
    Exit
    EndIf
If $M = $Exit Then
    TCPShutdown()
    Exit
    EndIf
If WinActive($Gui) And _IsPressed('OD') = '1' then _Send()
$Data =  TCPRecv($Con_Sock,'1000000')
If StringInStr($Data, '/Client.Disconnected') == '1' Then
_Disconnected()
ElseIf $Data <> '' Then
_Main_Log ('[' & _NowTime () & '] ' & $Data)
EndIf
sleep('10')
WEnd

Func _Send()
If GUICtrlRead($Send) <> ('') Then
$What_2_Send = GUICtrlRead($Input) & ' : Say(s) : ' & GUICtrlRead($Send)
$TCP_Send = TCPSend($Con_Sock,$What_2_Send)
If $TCP_Send >= '1' Then
_Main_Log('[' & _NowTime() & '] ' & $What_2_Send)
Else
_Disconnected()
EndIf
EndIf
GUICtrlSendMsg($Send, '')
EndFunc

Func _Main_Log($Data)
FileWriteLine(@tempdir & '/Server.Log', $Data)
$Read = FileRead(@TempDir & '/Server.Log')
GUICtrlSetData($Main,$Read)
_GUICtrlEdit_LineScroll($Main,'0',_GUICtrlEdit_GetLineCount($Main) - '1')
EndFunc

Func _Accept_Connection()
Do
sleep('10')
$Con_Sock = TCPAccept($Listen)
Until $Con_Sock <> ('-1')
_Main_Log('[' & _NowTime() & '] Client Has Connected.')
EndFunc

Func _Disconnected()
TCPCloseSocket($Con_Sock)
$Con_Sock = ('-1')
_Main_Log('[' & _NowTime() & '] Client Has Disconnected.')
Sleep(500)
_Main_Log('[' & _NowTime() & '] Waiting For Client To Connect.')
_Accept_Connection()
EndFunc

Func _Exit()
$S_Name = GUICtrlRead($Input)
exit
EndFunc

Func OnAutoItExit()
TCPSend($Con_Sock, '/Disconnect')
IniWrite ('Server_On_Load.ini','#Server','Username',' ' & $S_Name)
If FileExists(@tempdir & '/Server.Log') Then
$Msg = MsgBox(BitOr ('32','4'),'Delete?','Delete The Server.Log')
If $Msg <> '7' Then filedelete(@Tempdir & '/Server.Log')
EndIf
EndFunc

i dont really get an error, but when i try to send (with the server) nothing happens and when i send with John's Client TO this server it can recieve lol, any ideas as to what i have over looked?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...