|
| Author |
Message |
sk
Joined: 04 Oct 2007 Posts: 8
|
Posted: Sun Feb 24, 2008 1:06 am Post subject: Winsock control |
|
|
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 |
|
 |
Bob Riemersma
Joined: 27 Dec 2007 Posts: 54
|
Posted: Sat Feb 23, 2008 8:21 pm Post subject: Re: Winsock control |
|
|
"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 |
|
 |
Stefan Berglund
Joined: 04 Oct 2007 Posts: 636
|
Posted: Sat Feb 23, 2008 5:37 pm Post subject: Re: Winsock control |
|
|
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 |
|
 |
sk
Joined: 04 Oct 2007 Posts: 8
|
Posted: Sun Feb 24, 2008 1:55 am Post subject: Re: Winsock control |
|
|
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 |
|
 |
christery
Joined: 11 Jan 2008 Posts: 71
|
Posted: Sat Feb 23, 2008 7:25 pm Post subject: Re: Winsock control |
|
|
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 |
|
 |
Bob Butler
Joined: 04 Oct 2007 Posts: 1081
|
Posted: Sat Feb 23, 2008 10:28 pm Post subject: Re: Winsock control |
|
|
"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 |
|
 |
Kevin Provance
Joined: 04 Oct 2007 Posts: 800
|
Posted: Sun Feb 24, 2008 2:11 am Post subject: Re: Winsock control |
|
|
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 |
|
 |
Henning
Joined: 04 Oct 2007 Posts: 247
|
Posted: Sun Feb 24, 2008 11:40 pm Post subject: Re: Winsock control |
|
|
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
/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 |
|
 |
DanS
Joined: 04 Oct 2007 Posts: 212
|
Posted: Tue Feb 26, 2008 6:26 am Post subject: Re: Winsock control |
|
|
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 |
|
 |
|