Sign in to follow this  
Followers 0
mattmiester4

telnet server

2 posts in this topic

hello. ok, ive made a simple telnet server and everything is working pretty well so far. the one problem im having is that i dont know how to communicate from the client to the server in whole strings. the telnet window sends every character of data that i type. how can i manipulate the source so that it only returns the full string? for example, i want it to return "help" instead of "h", "e", "l", "p". thanks, matt

;----- 1/17/08 ----
;  Matthew Maughan
;  ssh server
;

#include <Array.au3>
#include <Color.au3>
#include <Constants.au3>
#include <Date.au3>
#include <File.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <Inet.au3>
#include <Math.au3>
#include <Memory.au3>
#include <Misc.au3>
#include <Process.au3>
#include <Sound.au3>
#include <Visa.au3>
#include <String.au3>

;----

HotKeySet("{End}", "Exxit")

;----

$PortMain = "225"
$MaxPConns = "100"
$CIP = "192.168.1.87"
$serverstatus = "0"; 1-connected 0-disconnected


;----

Dim $LSocket, $MSocket, $indatai

;----

service(1)
connlisten()

While 1
    
    $Msg = GUIGetMsg()
    
;conncheck()
;datarecv()
    
    if $serverstatus = 1 Then
        
        $indata = TCPRecv($MSocket, "2048")
            If $indata <> "" Then
                
                if $indata = "n" Then
                    Beep(1500, 50)
                ElseIf $indata = "m" Then
                ;...
                EndIf
            EndIf
    ElseIf $serverstatus = 0 Then
        connrecv()
    EndIf
        
    if $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
WEnd


Func service($ss)    ; start/stop service
    if $ss = 1 Then
        TCPStartup()
        $ss = -1
    ElseIf $ss = 0 Then
        TCPShutdown()
        $ss = -1
    EndIf
EndFunc

Func exxit()     ; Hotkey close
    Exit
EndFunc

Func connlisten()    ; Listen for connections...
    $LSocket = TCPListen($CIP, $PortMain, $MaxPConns)
EndFunc

Func datarecv()  ; checks for recieved data
; currently placed into while statememt for debuging purposes...
EndFunc

Func dsend($outdata)                            ; datasend
    TCPSend($MSocket, $outdata & @CRLF)
    $outdata = -1
EndFunc 

Func connrecv()  ; checks for incomming connections
    $MSocket = TCPAccept($LSocket)
    if $MSocket >= 0  Then
        TCPSend($MSocket, "Connection Established; Connected to " & @IPAddress1 & @CRLF)
        dsend("" & @CRLF)
        
        $i = 1
        
        Do          
            dsend(FileReadLine("greeting.txt", $i))
            $i = $i + "1"
        Until $i = 12 + 1

        $serverstatus = "1"
    EndIf
EndFunc

func conntest()  ; for debugging
;
EndFunc

Func conncheck()     ; continuously checks connection for changes
    If $serverstatus = "1" Then
        if $MSocket = -1 Then
            MsgBox(0, "", "Connection to client lost. reseting connection...", "2")
            $serverstatus = "0"
            service(1)
        EndIf
    ElseIf $serverstatus = "0" Then
    ;
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



I do not know the solution to your problem, but you probably should "bump" your original post on this topic rather than start a new one. Since you have already started a new one, you might want to delete your original post/topic:

http://www.autoitscript.com/forum/index.ph...showtopic=62111


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0