Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Come chat with me!
#1
Code: (Select All)
Dim Shared out$


Print "[Steve's Mini Messenger]"
client = _OpenClient("TCP/IP:7319:172.83.131.239") ' Attempt to connect to local host as a client
Print "[connected to " + _ConnectionAddress(client) + "]"

Input "Enter your name: ", myname$
out$ = myname$ + " connected!"
l = Len(out$)
Put #client, , l
Put #client, , out$
Do
    GetMessage client
    SendMessage myname$, mymessage$, client ' display current input on screen
    _Limit 30
Loop

'.................... END OF MAIN PROGRAM ................


Sub GetMessage (client) ' get & display any new message
    Get #client, , l
    If l > 0 Then
        _Delay .25
        out$ = Space$(l)
        Get #client, , out$
        View Print 1 To 20
        Locate 20, 1
        Print out$
        View Print 1 To 24
    Else
        out$ = ""
    End If
End Sub

Sub SendMessage (myname$, mymessage$, client) ' simple input handler
    k$ = InKey$
    If Len(k$) Then
        If k$ = Chr$(8) And Len(mymessage$) <> 0 Then
            mymessage$ = Left$(mymessage$, Len(mymessage$) - 1)
        Else
            If Len(k$) = 1 And Asc(k$) >= 32 Then mymessage$ = mymessage$ + k$
        End If
    End If
    View Print 1 To 24
    Locate 22, 1: Print Space$(80); ' erase previous message displayed
    Locate 22, 1: Print myname$ + ": "; mymessage$;
    If k$ = Chr$(13) Then ' [Enter] sends the message
        If mymessage$ = "" Then System ' [Enter] with no message ends program
        mymessage$ = myname$ + ":" + mymessage$
        l = Len(mymessage$)
        Put #client, , l
        Put #client, , mymessage$
        _Delay .25
        mymessage$ = ""
    End If
    If k$ = Chr$(27) Then System ' [Esc] key ends program
End Sub


There's been several folks who have been chatting and asking about TCP/IP communications between computers here lately, so I thought I'd showcase how it's done once again.

Above is a very simple client, which remotes out from your PC (you may have to open your firewall for it, or disable a few "protect yourself from yourself" settings, depending on your system), and which then connects to my laptop by which we can then chat happily with each other.

Feel free to hang around in the little chat all day with us, if you're able.  I'm going to keep the host up and going until after midnight EST for everyone, but that certainly doesn't mean I'm going to sit and hover over my laptop that whole time to always be available to instantly say, "HEY!  I SEE YOU!  CAN YOU HEAR ME NOW??"

The more folks who pop in and hang around, the more folks who can chatter with each other and welcome someone new into the channel, so they can be certain that the program is working and communicating in both directions for them.  

If all this works, without folks having too hard an issue running with it, I'll post the host and client both sometime tomorrow and then try and walk everyone through all the steps I went through to get it to play nicely with my router, firewall, and all.  Wink
Reply


Messages In This Thread
Come chat with me! - by SMcNeill - 12-10-2022, 12:06 PM
RE: Come chat with me! - by mnrvovrfc - 12-10-2022, 03:06 PM
RE: Come chat with me! - by SMcNeill - 12-10-2022, 05:13 PM
RE: Come chat with me! - by Pete - 12-10-2022, 05:29 PM
RE: Come chat with me! - by mnrvovrfc - 12-11-2022, 03:01 AM
RE: Come chat with me! - by Dav - 12-11-2022, 03:35 AM
RE: Come chat with me! - by mnrvovrfc - 12-11-2022, 08:29 AM



Users browsing this thread: 2 Guest(s)