Board index » cppbuilder » TNMMSG component can't change IP at runtime?

TNMMSG component can't change IP at runtime?

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

 

Re:TNMMSG component can't change IP at runtime?


"JP" <jaa...@hetnet.nl> schreef in bericht
news:elvlB4QmAHA.188@net037s.hetnet.nl...

Quote
> 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 -

Re:TNMMSG component can't change IP at runtime?


Thanks a lot!!!!!

Zweater <news_zwea...@hotmail.com> schreef in berichtnieuws
3a9d86bd$0$13501@reader3...

Quote
> "JP" <jaa...@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 -

Other Threads