<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mcselec.com/bavr/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=GETDSTPORT</id>
		<title>GETDSTPORT - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=GETDSTPORT"/>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=GETDSTPORT&amp;action=history"/>
		<updated>2026-04-05T16:56:10Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.6</generator>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=GETDSTPORT&amp;diff=676&amp;oldid=prev</id>
		<title>Admin at 17:34, 11 February 2013</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=GETDSTPORT&amp;diff=676&amp;oldid=prev"/>
				<updated>2013-02-11T17:34:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:34, 11 February 2013&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 46:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 46:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/config_tcpip.htm &lt;/del&gt;CONFIG TCPIP],&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/getsocket.htm &lt;/del&gt;GETSOCKET]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/socketconnect.htm &lt;/del&gt;SOCKETCONNECT],&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/socketstat.htm &lt;/del&gt;SOCKETSTAT]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/tcpwrite.htm &lt;/del&gt;TCPWRITE],&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/tcpwritestr.htm &lt;/del&gt;TCPWRITESTR],&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/socketclose.htm &lt;/del&gt;CLOSESOCKET]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;,[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/socketlisten.htm &lt;/del&gt;SOCKETLISTEN]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;nbsp;&lt;/del&gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/getdstip.htm &lt;/del&gt;GETDSTIP]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;CONFIG TCPIP&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;], [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;GETSOCKET]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;] &lt;/ins&gt;, [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;SOCKETCONNECT&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;], [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;SOCKETSTAT]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;] &lt;/ins&gt;, [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;TCPWRITE&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;], [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;TCPWRITESTR&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;], [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;CLOSESOCKET]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;] &lt;/ins&gt;,[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;SOCKETLISTEN]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;] &lt;/ins&gt;, [&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;GETDSTIP&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=GETDSTPORT&amp;diff=675&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;= &lt;span class=&quot;f_Header&quot;&gt;Action&lt;/span&gt; =  Returns the port number of the peer.  &lt;span style=&quot;font-family: Arial;&quot;&gt;&amp;nbsp;&lt;/span&gt;  &lt;span style=&quot;font-family: Arial;&quot;&gt;&amp;nbsp;&lt;/span...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=GETDSTPORT&amp;diff=675&amp;oldid=prev"/>
				<updated>2013-02-11T17:33:40Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =  Returns the port number of the peer.  &amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;  &amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt; &amp;lt;/span...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
Returns the port number of the peer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Syntax&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
Result =&amp;amp;nbsp;&amp;lt;span class=&amp;quot;f_Syntax&amp;quot;&amp;gt;GETDSTPort&amp;lt;/span&amp;gt;( socket)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Remarks&amp;lt;/span&amp;gt; =&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0px; margin: 0px 0px 0px 4px;&amp;quot;&amp;gt;&lt;br /&gt;
{| width=&amp;quot;609&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot; border=&amp;quot;1&amp;quot; style=&amp;quot;border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;17%&amp;quot; style=&amp;quot;width: 100px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Result&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;width: 500px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
A WORD variable that is assigned with the port number of the peer or destination port number.&lt;br /&gt;
&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;17%&amp;quot; style=&amp;quot;width: 100px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Socket&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;width: 500px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
The socket number in the range from 0-3&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you are in server mode, it might be desirable to detect the port number of the connecting client.&lt;br /&gt;
&lt;br /&gt;
You can use this for logging, security, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[http://avrhelp.mcselec.com/config_tcpip.htm CONFIG TCPIP],&amp;amp;nbsp;[http://avrhelp.mcselec.com/getsocket.htm GETSOCKET]&amp;amp;nbsp;,&amp;amp;nbsp;[http://avrhelp.mcselec.com/socketconnect.htm SOCKETCONNECT],&amp;amp;nbsp;[http://avrhelp.mcselec.com/socketstat.htm SOCKETSTAT]&amp;amp;nbsp;,&amp;amp;nbsp;[http://avrhelp.mcselec.com/tcpwrite.htm TCPWRITE],&amp;amp;nbsp;[http://avrhelp.mcselec.com/tcpwritestr.htm TCPWRITESTR],&amp;amp;nbsp;[http://avrhelp.mcselec.com/socketclose.htm CLOSESOCKET]&amp;amp;nbsp;,[http://avrhelp.mcselec.com/socketlisten.htm SOCKETLISTEN]&amp;amp;nbsp;,&amp;amp;nbsp;[http://avrhelp.mcselec.com/getdstip.htm GETDSTIP]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Example&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;source lang=&amp;quot;bascomavr&amp;quot;&amp;gt;&lt;br /&gt;
'-----------------------------------------------------------------------------------------&lt;br /&gt;
'name : servertest_TWI.bas&lt;br /&gt;
'copyright : (c) 1995-2012, MCS Electronics&lt;br /&gt;
'purpose : start the easytcp after the chip is programmed&lt;br /&gt;
' and create 2 connections&lt;br /&gt;
'micro : Mega88&lt;br /&gt;
'suited for demo : no&lt;br /&gt;
'commercial addon needed : yes&lt;br /&gt;
'-----------------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
$regfile = &amp;quot;m88def.dat&amp;quot; ' specify the used micro&lt;br /&gt;
$crystal = 8000000 ' used crystal frequency&lt;br /&gt;
$baud = 19200 ' use baud rate&lt;br /&gt;
 &lt;br /&gt;
$hwstack = 128 ' default use 32 for the hardware stack&lt;br /&gt;
$swstack = 128 ' default use 10 for the SW stack&lt;br /&gt;
$framesize = 128 ' default use 40 for the frame space&lt;br /&gt;
 ' xram access&lt;br /&gt;
Print &amp;quot;Init , set IP to 192.168.1.70&amp;quot; ' display a message&lt;br /&gt;
Enable Interrupts ' before we use config tcpip , we need to enable the interrupts&lt;br /&gt;
Config Tcpip = Int1 , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.70 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Tx = $55 , Rx = $55 , Chip = W5100 , Spi = 1&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Dim Bclient As Byte ' socket number&lt;br /&gt;
Dim Idx As Byte&lt;br /&gt;
Dim Result As Word , Result2 As Word ' result&lt;br /&gt;
Dim S As String * 80&lt;br /&gt;
Dim Flags As Byte&lt;br /&gt;
Dim Peer As Long&lt;br /&gt;
Dim L As Long&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Do&lt;br /&gt;
Waitms 1000&lt;br /&gt;
For Idx = 0 To 3&lt;br /&gt;
 Result = Socketstat(idx , 0) ' get status&lt;br /&gt;
 Select Case Result&lt;br /&gt;
 Case Sock_established&lt;br /&gt;
 If Flags.idx = 0 Then ' if we did not send a welcome message yet&lt;br /&gt;
 Flags.idx = 1&lt;br /&gt;
 Result = Tcpwrite(idx , &amp;quot;Hello from W3100A{013}{010}&amp;quot;) ' send welcome&lt;br /&gt;
 End If&lt;br /&gt;
 Result = Socketstat(idx , Sel_recv) ' get number of bytes waiting&lt;br /&gt;
 Print &amp;quot;Received : &amp;quot; ; Result&lt;br /&gt;
 If Result &amp;gt; 0 Then&lt;br /&gt;
 Do&lt;br /&gt;
 Print &amp;quot;Result : &amp;quot; ; Result&lt;br /&gt;
 Result = Tcpread(idx , S)&lt;br /&gt;
 Print &amp;quot;Data from client: &amp;quot; ; Idx ; &amp;quot; &amp;quot; ; Result ; &amp;quot; &amp;quot; ; S&lt;br /&gt;
 Peer = Getdstip(idx)&lt;br /&gt;
 Print &amp;quot;Peer IP &amp;quot; ; Ip2str(peer)&lt;br /&gt;
 Print &amp;quot;Peer port : &amp;quot; ; Getdstport(idx)&lt;br /&gt;
 'you could analyse the string here and send an appropiate command&lt;br /&gt;
 'only exit is recognized&lt;br /&gt;
 If Lcase(s) = &amp;quot;exit&amp;quot; Then&lt;br /&gt;
 Closesocket Idx&lt;br /&gt;
 Elseif Lcase(s) = &amp;quot;time&amp;quot; Then&lt;br /&gt;
 Result2 = Tcpwrite(idx , &amp;quot;12:00:00{013}{010}&amp;quot;) ' you should send date$ or time$&lt;br /&gt;
 End If&lt;br /&gt;
 Loop Until Result = 0&lt;br /&gt;
 End If&lt;br /&gt;
 Case Sock_close_wait&lt;br /&gt;
 Print &amp;quot;close_wait&amp;quot;&lt;br /&gt;
 Closesocket Idx&lt;br /&gt;
 Case Sock_closed&lt;br /&gt;
 Print &amp;quot;closed&amp;quot;&lt;br /&gt;
 Bclient = Getsocket(idx , Sock_stream , 5000 , 64) ' get socket for server mode, specify port 5000&lt;br /&gt;
 Print &amp;quot;Socket &amp;quot; ; Idx ; &amp;quot; &amp;quot; ; Bclient&lt;br /&gt;
 &lt;br /&gt;
 Socketlisten Idx&lt;br /&gt;
 Print &amp;quot;Result &amp;quot; ; Result&lt;br /&gt;
 Flags.idx = 0 ' reset the hello message flag&lt;br /&gt;
 Case Sock_listen 'this is normal&lt;br /&gt;
 Case Else&lt;br /&gt;
 Print &amp;quot;Socket status : &amp;quot; ; Result&lt;br /&gt;
 End Select&lt;br /&gt;
Next&lt;br /&gt;
Loop&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;br/&amp;gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
[[Category:BASCOM Language Reference]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>