TCP/UDP/IP Question[s]

Blitz3D Forums/Blitz3D Programming/TCP/UDP/IP Question[s]

Hey all,

So, I'm knocking together a Chat program for some friends & me. Yes I KNOW there are a brazillion or more Chat APPs out there, but I want to make one. So there. XP

Anyway, let's say a friend & I are both online with our programs running. My IP is, say, 111.111.111.111, and my friend's is 222.222.222.222. My friend, however, is in the next town/county/state, so is no part of my LAN. Now, let's say we both have TCP servers created & running for our Chat programs, like:

Me-
ServerPort = 1234567
ChatServer = CreateTCPServer(ServerPort)


Friend-
ServerPort = 7654321
ChatServer = CreateTCPServer(ServerPort)


Both our programs are listening for messages from the other, with some code like:

Repeat
    InStream = AcceptTCPStream(ChatServer)
Until InStream


Then, my program sends a TCP stream to my friend's APP (still listening,) with something like:

OutStream = OpenTCPStream("222.222.222.222",7654321)

If OutStream
    WriteString OutStream,"Ahoy!"
    WriteString OutStream,"Anyone out there?"
    CloseTCPStream(OutStream)
EndIf


Assuming my friend's APP is still listening, would this code work, and the message be recieved? Or would I have to use UDP, or some other method altogether?

What, no tips whatsoever??

Now u know how i feel.. u sometimes have to wait over 2 days to get a reply. just be patient.

Poor, poor you's. I really feel for you, waiting for people to reply on this forum, where folks come (in their free time) to help those in need. Maybe i'm just having a bad day, but you really come across ungrateful.

Yes something like that would work. Have a look at my code archives entry.

And regarding 'no tips yet' - some of us live in other parts of the world. 6 hours ago, when you posted that it was 6am here.

Ross - and anyone else who's reading this - I'm sorry if I seemed ungrateful. In retrospect, it does rather seem that way, but I really didn't mean to be.

I am ENORMOUSLY grateful to all the people who help out on these forums, none of whom are reqiured to do this by any means. I don't mind waiting for an answer at all; the only time I post one of those "Anyone?" lines is when my post is in danger of slipping away unanswered, and being forgotten. I just do it to bump it back to the front. And I never do that more than once.

No worries. As i say, probably just having a bad day yesterday...

Well, you still did have a point. Plus, I always enjoy well-placed, well thought out sarcasm. ^_^

Where is the readline command ?

Erm, probably something like...

Repeat
    Local StreamIn = AcceptTCPStream(ChatServer)
Until StreamIn

While Not Eof(StreamIn)
    Print ReadString(StreamIn)
Wend


i belive you have to rethink a little.

tcp works difirent.

tcp you open 1 stream and use it for both read and write.