Article View: alt.comp.programming
Article #25Re: TNMMSG component can't change IP at runtime?
From: Zweater
Date: Wed, 28 Feb 2001 23:15
Date: Wed, 28 Feb 2001 23:15
59 lines
4495 bytes
4495 bytes
"JP" <jaapjp@hetnet.nl> schreef in bericht
news:elvlB4QmAHA.188@net037s.hetnet.nl...
> I've got the following problem :
>
> I've spent the last few days creating a little chat-program for our own
LAN.
> It seems to work quite well, but only when I'm still using the IP-adress
> that's been set at design-time. After I've changed the IP at runtime, it
> won't work anymore. I change the IP via a string which contains the dotted
> IP-adress, thus which contains something like "192.168.0.5". I've verified
> that the IP-adress is right, and that the component has recyved the new IP
> adress correctley ( did a Memo -> Lines -> Add ("(" + MessageClient ->
Host
> + ")"); ). I've tried out the app with IP-adresses set at desgn-time over
> my LAN, that works. As soon as I change the adress at runtime, even if it
is
> the same adress as the one which I set at design-time, it won't work
> anymore. I've made a keypressed event so that whenever a user types a
> sentence and presses enter, the typed sentence is sent to the server.
After
> I changed the IP-adress, the first time I press enter, the server just
> doesn't recyve the message. The next time the client gives the error
> "Already connected", and then the program stops responding. I have to kill
> it using CTRL + ALT + DEL. Does anyone know what I'm doing wrong? I've
read
> that the Host property can be set at runtime... What's going on?
>
> Thanks,
>
> JP
I've just got bcb 3 installed here - bcb4 not installed and bcb5 I got
doesn't have fastnet controls
Anyway, in bcb3 the component has a method called Abort. I suggest you call
this function
*before* you assign a new IP address.
I als have another suggestion: why not use the TClientSocket / TServerSocket
components.
They are really easy to use, and much more flexible than the fastnet msg
component.
Using that components, you can make / break a connection using Open() and
Close().
Make sure you close the connection first BEFORE changing the IP address.
All errors can be catched if you add a handler to the OnError event, after
you
add a line to a memobox or something set ErrorCode to 0 and you're done.
Sending text in the ClientSocket:
ClientSocket1->Socket->SendText("bla bla bla");
In the serversocket:
ServerSocket1->Socket->Connections[clientnumber]->SendText("bla bla bla");
Receiving: add a OnRead handler. Use something like
Memo1->Lines->Add( Socket->ReceiveText( ) );
- Zweater -
Technical Details
Message-ID:
<3a9d86bd$0$13501@reader3>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed.icl.net!dispose.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!diablo.netcom.net.uk!netcom.net.uk!news-hub.siol.net!newsfeed.wirehub.nl!news2.euro.net!cleanfeed.casema.net!news.casema.net!not-for-mailReferences:
<elvlB4QmAHA.188@net037s.hetnet.nl>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8d38,3018f1587c24d03a X-Google-Attributes: gidf8d38,public X-Google-Thread: 10640b,3018f1587c24d03a X-Google-Attributes: gid10640b,public X-Google-Thread: 102541,3018f1587c24d03a X-Google-Attributes: gid102541,public X-Google-Thread: 10dce5,3018f1587c24d03a X-Google-Attributes: gid10dce5,public X-Google-Thread: 103c8d,3018f1587c24d03a X-Google-Attributes: gid103c8d,public X-Google-Thread: feb9e,3018f1587c24d03a X-Google-Attributes: gidfeb9e,public X-Google-Thread: 10fbec,3018f1587c24d03a X-Google-Attributes: gid10fbec,public X-Google-Thread: 10a78a,3018f1587c24d03a X-Google-Attributes: gid10a78a,public X-Google-ArrivalTime: 2001-02-28 15:30:06 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed.icl.net!dispose.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!diablo.netcom.net.uk!netcom.net.uk!news-hub.siol.net!newsfeed.wirehub.nl!news2.euro.net!cleanfeed.casema.net!news.casema.net!not-for-mail From: "Zweater" <news_zweater@hotmail.com> Newsgroups: alt.comp.programming,alt.support.programming,borland.public.cpp.ide,borland.public.cpp.language,borland.public.cppbuilder.ide,borland.public.cppbuilder.language,borland.public.cppbuilder.students,forum.advanced.programming References: <elvlB4QmAHA.188@net037s.hetnet.nl> Subject: Re: TNMMSG component can't change IP at runtime? Date: Thu, 1 Mar 2001 00:15:13 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Lines: 61 Message-ID: <3a9d86bd$0$13501@reader3> NNTP-Posting-Host: 11dyn60.boll.casema.net X-Trace: reader3 983402173 13501 212.64.126.60 X-Complaints-To: http://www.casema.net/abuse X-Abuse-Info: Please be sure to include a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Server-Date: 28 Feb 2001 23:16:13 GMT