The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: An Ethernet question


  • Subject: Re: An Ethernet question
  • From: Stuart Booth
  • Date: Tue, 16 Sep 2003 09:54:00 +0000

On Tue, 16 Sep 2003 00:00:55 +0100, "Ian B" <<a
href="/group/xAP_developer/post?postID=3UioBBSgPyUDzf7zeCjeYK_u7nPOLaFmz6S4CGX4n_UieqBgfyV0TUcXFZ6wihmj82mEorTZPjrTDg">Ian@M...</a>>
wrote:

>I am still looking at this (perseverance!!) and I have a port question
or
>three.

I'll give them a go. I'm no network programming wiz. About all I've
really done so far, unfortunately, is my xAP stuff.

>What are they?

If I've understood your question correctly, every machine has a large
range of individual port numbers, 1 through 65536 I'd guess. Different
services listen on different port numbers, 20/21 for FTP, 80 for HTTP
I believe it is. xAP's port is 3639 if memory serves.

Is that what you meant?

>On my micro do I have to listen on the same port as you are
transmitting?

I seem to recall something about reading from and writing to the same
port but I can't recall the details. I don't with my software, I think
it will fail to open a port for transmission that has already been
opened for receiving.

The xAP Hub opens port 3639 for listening. The xAPSender class in my
framework that I snatched the code below from attempts to open a port
to send on, starting from either 3639 or 3640 more likely. When it
succeeds in this it has found an unused port it can write out on.

Originally I just let the sender class open any port it cared to, but
Kevin I think it was suggested working up from the official xAP port#.

So the transmission port is really irrelevant, it's the listening port
that's important.

> If
>so how do I know which one you are using? Is this the same port there
was
>discussion about earlier and it was assigned by some body or other.

Ahhh, the Hub protocol. Each of my Hub Client apps uses an instance of
a xAPListener derived class to receive messages. This will have
scanned up the range of ports looking for a free one to listen on in
much the same manner as the xAPSender class. Once it finds one the
client transmits this port number in the h/b so that the Hub knows
what port the client is listening on.

So it's in the process of finding a port that I can successfully open
that I determine which one I'll use. I don't know how that will
translate to your micro though!

If I recall correctly (I wrote this code in November last year) that's
how my Hub/Client auto-detection works. If port 3639 is unavailable it
starts as a HubClient application rather than a Hub, assuming that a
Hub is already running.

>I assume if IP is used there is no port number - is this correct?

No, I don't believe. You're connecting to a particular port on a
particular machine. Different ports require separate connections. UDP
broadcasts are still transmitted to a receiving port number.

One of these days I'll read up more on all of this, but I'm struggling
for time as it is already. Hey, Ian (Lowe :), sorry I haven't done
much on the xPL front yet. That's not through lack of interest I
assure you!! Too many projects and not enough spare time.

HTH?

S

>>-----Original Message-----
>>From: Stuart Booth [mailto:<a
href="/group/xAP_developer/post?postID=k58cLvqcWDnAXDjsI7xVoU58UqRdUGxbWTUfmR5VRTMEjXO3o7PCmHU2YXimzVoEvjS6qTzLVb5bSOB5">lists@x...</a>]
>>Sent: 11 September 2003 10:49
>>To: <a
href="/group/xAP_developer/post?postID=lprPgiCugSVxXUjl2HMQ0PFIeiWfrebBN3VMkxJ6lHnJahDBVLkACKB-wSLjxlNB3foDprlMmJ2hZMfTQqhxG8hCGis">xAP_developer@xxxxxxx</a>
>>Subject: Re: [xAP_developer] An Ethernet question
>>
>>
>>On Thu, 11 Sep 2003 08:52:54 -0000, "Ian Bird" <<a
href="/group/xAP_developer/post?postID=3UioBBSgPyUDzf7zeCjeYK_u7nPOLaFmz6S4CGX4n_UieqBgfyV0TUcXFZ6wihmj82mEorTZPjrTDg">Ian@M...</a>>
>>wrote:
>>
>>>If so, when writing a PC based application do you somehow
specify the
>>>method used to send a xAP message in the program?
>>
>>I do. My framework code to send a message goes something like this:
>>
>>private void Connect ()
>>{
>> int port = xAPTransportInfo.GetListeningPort();
>> IPEndPoint ep = new IPEndPoint(IPAddress.Broadcast, port);
>>
>> UdpClient m_datagram = new UdpClient();
>> m_datagram.Connect(ep);
>>} // End of Connect
>>
>>public void Send (xAPMessage message)
>>{
>> byte[] msg =
Encoding.ASCII.GetBytes(message.ToRawMessageString());
>>
>> m_datagram.Send(msg, msg.Length);
>>} // End of Send
>>
>>So it's all encapsulated in the UdpClient class of the Microsoft
.net
>>Framework. More than that I haven't really needed to know. There
are
>>TcpClient classes as well which I use to communicate directly with
my
>>TiVo's YAC listener.

--
Stuart Booth
xAPFramework.net - a reusable xAP framework for .net

<a href="http://www.xapframework.net/";>http://www.xapframework.net/</a>
<a
href="/group/xAP_developer/post?postID=tATVknTSDTzdt9c3Iimx8lWEe0phnoea-ck9GDkJjOeols7RFPl1S-O7hNwl7HSOVOoYUyZADpMg3UTdXO1z">stuart@x...</a>





xAP_Development Main Index | xAP_Development Thread Index | xAP_Development Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.