msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Winsock control

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions
Author Message
sk



Joined: 04 Oct 2007
Posts: 8

PostPosted: Sun Feb 24, 2008 1:06 am    Post subject: Winsock control Reply with quote

In my project I would like to listen to certain port. That's why I created
usercontrol with the winsock control on in the problem is, that with every
initialization of this usercontrol in my project I get an error "Address in
use"?

The problem is that I need to listen to the port on the multiple ports in my
project ...

Am I in the dead valley or ...?

I would be very glad to hear your suggestions on how to deal with this thing

SK

Archived from group: microsoft>public>vb>general>discussion
Back to top
View user's profile Send private message
Bob Riemersma



Joined: 27 Dec 2007
Posts: 54

PostPosted: Sat Feb 23, 2008 8:21 pm    Post subject: Re: Winsock control Reply with quote

"sk" wrote in message %vj.6450$HS3.347676@news.siol.net...
> In my project I would like to listen to certain port. That's why I created
> usercontrol with the winsock control on in the problem is, that with every
> initialization of this usercontrol in my project I get an error "Address
> in
> use"?
>
> The problem is that I need to listen to the port on the multiple ports in
> my
> project ...
>
> Am I in the dead valley or ...?
>
> I would be very glad to hear your suggestions on how to deal with this
> thing
>
> SK

Without more information I'd think something else is already bound to the
port number in question. Only one process can be bound to any given IP
Address/Port Number combo at a time.

We'd have to know more about what you're trying to accomplish (and how)
before we could tell you much more I'd think.

"... listen to the port on the multiple ports..." reads like nonsense. Can
you be more specific and expressive here? It almost sounds as if you are
trying to use multiple sockets, all listening on ther same port number. To
my limited knowledge that won't work.
Back to top
View user's profile Send private message
Stefan Berglund



Joined: 04 Oct 2007
Posts: 636

PostPosted: Sat Feb 23, 2008 5:37 pm    Post subject: Re: Winsock control Reply with quote

On Sat, 23 Feb 2008 15:21:01 -0500, "Bob Riemersma"
wrote:
in

>"sk" wrote in message
>%vj.6450$HS3.347676@news.siol.net...
>> In my project I would like to listen to certain port. That's why I created
>> usercontrol with the winsock control on in the problem is, that with every
>> initialization of this usercontrol in my project I get an error "Address
>> in
>> use"?
>>
>> The problem is that I need to listen to the port on the multiple ports in
>> my
>> project ...
>>
>> Am I in the dead valley or ...?
>>
>> I would be very glad to hear your suggestions on how to deal with this
>> thing
>>
>> SK
>
>Without more information I'd think something else is already bound to the
>port number in question. Only one process can be bound to any given IP
>Address/Port Number combo at a time.
>
>We'd have to know more about what you're trying to accomplish (and how)
>before we could tell you much more I'd think.
>
>"... listen to the port on the multiple ports..." reads like nonsense. Can
>you be more specific and expressive here? It almost sounds as if you are
>trying to use multiple sockets, all listening on ther same port number. To
>my limited knowledge that won't work.

I'd say from the "in the dead valley" phrase that the poster is clearly
in the English as a SECOND language category. In fact, intuitively
obvious to the most casual observer...

---
Stefan Berglund
Back to top
View user's profile Send private message
sk



Joined: 04 Oct 2007
Posts: 8

PostPosted: Sun Feb 24, 2008 1:55 am    Post subject: Re: Winsock control Reply with quote

I meant forms not ports ... my mistake ... sorry

And no, English is not my second language ... it is not even third ...

SK

Stefan Berglund wrote:
>On Sat, 23 Feb 2008 15:21:01 -0500, "Bob Riemersma"
>wrote:
> in
>
>>"sk" wrote in message
>>%vj.6450$HS3.347676@news.siol.net...
>>> In my project I would like to listen to certain port. That's why I created
>>> usercontrol with the winsock control on in the problem is, that with every
>>> initialization of this usercontrol in my project I get an error "Address
>>> in
>>> use"?
>>>
>>> The problem is that I need to listen to the port on the multiple ports in
>>> my
>>> project ...
>>>
>>> Am I in the dead valley or ...?
>>>
>>> I would be very glad to hear your suggestions on how to deal with this
>>> thing
>>>
>>> SK
>>
>>Without more information I'd think something else is already bound to the
>>port number in question. Only one process can be bound to any given IP
>>Address/Port Number combo at a time.
>>
>>We'd have to know more about what you're trying to accomplish (and how)
>>before we could tell you much more I'd think.
>>
>>"... listen to the port on the multiple ports..." reads like nonsense. Can
>>you be more specific and expressive here? It almost sounds as if you are
>>trying to use multiple sockets, all listening on ther same port number. To
>>my limited knowledge that won't work.
>
>I'd say from the "in the dead valley" phrase that the poster is clearly
>in the English as a SECOND language category. In fact, intuitively
>obvious to the most casual observer...
>
>---
>Stefan Berglund
Back to top
View user's profile Send private message
christery



Joined: 11 Jan 2008
Posts: 71

PostPosted: Sat Feb 23, 2008 7:25 pm    Post subject: Re: Winsock control Reply with quote

On 23 Feb, 21:06, s...@email.si (sk) wrote:
> In my project I would like to listen to certain port. That's why I created
> usercontrol with the winsock control on in the problem is, that with every
> initialization of this usercontrol in my project I get an error "Address in
> use"?
>
> The problem is that I need to listen to the port on the multiple ports in my
> project ...
>
> Am I in the dead valley or ...?
>
> I would be very glad to hear your suggestions on how to deal with this thing
>
> SK

Last time you asked how to check/control if a serial (MSCOMM) message
is complete, and now asking for listening to a port on multiple
ports... I have a slight idea that you are from Serbia but that doesnt
mean that I still can read your mind... to read a port - there should
be lots of code examples, to go into promiscues mode like net stumbler
then it kills the built in windows management whilst running... it can
be done but why?
//CY
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Sat Feb 23, 2008 10:28 pm    Post subject: Re: Winsock control Reply with quote

"sk" wrote in message %vj.6451$HS3.347492@news.siol.net...
>I meant forms not ports ... my mistake ... sorry
>
> And no, English is not my second language ... it is not even third ...

Have 1 form listen on the port and send anything it gets to all the other
forms by some other means (e.g. call a public Sub on each form in the Forms
collection that is the correct type).
Back to top
View user's profile Send private message
Kevin Provance



Joined: 04 Oct 2007
Posts: 800

PostPosted: Sun Feb 24, 2008 2:11 am    Post subject: Re: Winsock control Reply with quote

Speaking of English not being the first language.


wrote in message @e6g2000prf.googlegroups.com...
| On 23 Feb, 21:06, s...@email.si (sk) wrote:
| > In my project I would like to listen to certain port. That's why I
created
| > usercontrol with the winsock control on in the problem is, that with
every
| > initialization of this usercontrol in my project I get an error "Address
in
| > use"?
| >
| > The problem is that I need to listen to the port on the multiple ports
in my
| > project ...
| >
| > Am I in the dead valley or ...?
| >
| > I would be very glad to hear your suggestions on how to deal with this
thing
| >
| > SK
|
| Last time you asked how to check/control if a serial (MSCOMM) message
| is complete, and now asking for listening to a port on multiple
| ports... I have a slight idea that you are from Serbia but that doesnt
| mean that I still can read your mind... to read a port - there should
| be lots of code examples, to go into promiscues mode like net stumbler
| then it kills the built in windows management whilst running... it can
| be done but why?
| //CY
Back to top
View user's profile Send private message
Henning



Joined: 04 Oct 2007
Posts: 247

PostPosted: Sun Feb 24, 2008 11:40 pm    Post subject: Re: Winsock control Reply with quote

One not natural English spoken to another, som air-code to get you going.

You can only Bind a port to _one_ winsock control.

For TCP in the ConnectionRequest event, decide to .Accept the call.

In a .bas module add.
Public MyActiveForm As Integer
Public MyWSData as String

In each Form's Activate event.
MyActiveForm = (1,2,3,4... or whatever you like)

On each Form add.
Sub TCPDataRec()
'handle the incomming data packet in MyWSData in this form
....
End Sub

In the WinSock DataArrival event
.....
YourWSControlName.GetData MyWSData
If MyActiveForm = 1 Then
Form1.TCPDataRec()
ElseIf MyActiveForm = 2 Then
Form2.TCPDataRec()
ElseIf MyActiveForm = 3 Then
Form3.TCPDataRec()
.....
End If

At least a point to start argueing... If nothing else, the Public variable
will Wink

/Henning

"sk" skrev i meddelandet %vj.6451$HS3.347492@news.siol.net...
>I meant forms not ports ... my mistake ... sorry
>
> And no, English is not my second language ... it is not even third ...
>
> SK
>
> Stefan Berglund wrote:
>>On Sat, 23 Feb 2008 15:21:01 -0500, "Bob Riemersma"
>>wrote:
>> in
>>
>>>"sk" wrote in message
>>>%vj.6450$HS3.347676@news.siol.net...
>>>> In my project I would like to listen to certain port. That's why I
>>>> created
>>>> usercontrol with the winsock control on in the problem is, that with
>>>> every
>>>> initialization of this usercontrol in my project I get an error
>>>> "Address
>>>> in
>>>> use"?
>>>>
>>>> The problem is that I need to listen to the port on the multiple ports
>>>> in
>>>> my
>>>> project ...
>>>>
>>>> Am I in the dead valley or ...?
>>>>
>>>> I would be very glad to hear your suggestions on how to deal with this
>>>> thing
>>>>
>>>> SK
>>>
>>>Without more information I'd think something else is already bound to the
>>>port number in question. Only one process can be bound to any given IP
>>>Address/Port Number combo at a time.
>>>
>>>We'd have to know more about what you're trying to accomplish (and how)
>>>before we could tell you much more I'd think.
>>>
>>>"... listen to the port on the multiple ports..." reads like nonsense.
>>>Can
>>>you be more specific and expressive here? It almost sounds as if you are
>>>trying to use multiple sockets, all listening on ther same port number.
>>>To
>>>my limited knowledge that won't work.
>>
>>I'd say from the "in the dead valley" phrase that the poster is clearly
>>in the English as a SECOND language category. In fact, intuitively
>>obvious to the most casual observer...
>>
>>---
>>Stefan Berglund
>
>
>
Back to top
View user's profile Send private message
DanS



Joined: 04 Oct 2007
Posts: 212

PostPosted: Tue Feb 26, 2008 6:26 am    Post subject: Re: Winsock control Reply with quote

sk@email.si (sk) wrote in %vj.6450$HS3.347676@news.siol.net:

> In my project I would like to listen to certain port. That's why I
> created usercontrol with the winsock control on in the problem is,
> that with every initialization of this usercontrol in my project I get
> an error "Address in use"?
>
> The problem is that I need to listen to the port on the multiple ports
> in my project ...
>
> Am I in the dead valley or ...?
>
> I would be very glad to hear your suggestions on how to deal with this
> thing
>
> SK
>

I'll actually answer your question for you here.

Accepting many connections on one IP port requires 1 Winsock control for
each connection you want to accept.

Winsock1 is listening on port 68 (or whatever port).

The Winsock1 ConnectRequest event fires when something tries to connect.

The ConnectRequest event also recevies a RequestID when it is fired.

You do not accept the connection with this Winsock control!

Instead, you create another Winsock control, say Winsock2, then call
Winsock2.Accept passing the RequestID as an argument.

What this does is hand off the connection to the 2nd Winsock control, and
the second Winsock control accepts the connection, and automatically
negotiates with whatever is connecting to use a different port, you do
not need to specify a port.

This now leaves the original Winsock control still listening on the
original port waiting to receive more connections and hands them each off
to even more Winsock Controls that you create.

It may be best to use a control array for the Winsock control. You can
listen with Winsock(0), and load and unload elements as necessary.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group