From WikiChip
Editing mirc/commands/sockudp

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|/sockudp Command}}
+
The '''/sockudp command''' allows you to send data to a specific address at a specific port destination. Check out the UDP article [[UDP Sockets - mIRC|here]]
The '''/sockudp command''' allows you to send data to a specific address at a specific port destination (See {{mIRC|UDP sockets}}).
 
  
'''Note''': if /sockudp fails, it sets {{mIRC|$sock|$sock().wserr}} to the error value, and trigger on sockwrite with {{mIRC|$sockerr}} set etc.
+
'''Note''': if /sockudp fails, it sets $sock().wserr to the error value, and trigger on sockwrite with $sockerr set etc.
  
 
== Synopsis ==
 
== Synopsis ==
/sockudp -bntkduz [bindip] <name> [port] <ipaddress> <port> [numbytes] [text|%var|&binvar]
+
/sockudp -bntkd [bindip] <name> [port] <ipaddress> <port> [numbytes] [text|%var|&binvar]
  
 
== Switches ==
 
== Switches ==
 
* '''-b''' - Indicates that you are specifying the numbytes value which is the number of bytes you want send, the full line is sent otherwise
 
* '''-b''' - Indicates that you are specifying the numbytes value which is the number of bytes you want send, the full line is sent otherwise
* '''-n''' - Appens a {{mIRC|$crlf}} to the line being sent if it's not a &binvar or if does not already end with a $crlf
+
* '''-n''' - Appens a $crlf to the line being sent if it's not a &binvar or if does not already end with a $crlf
 
* '''-t''' - Forces mIRC to send anything beginning with a & as plain text
 
* '''-t''' - Forces mIRC to send anything beginning with a & as plain text
 
* '''-k''' - Keeps the socket opened
 
* '''-k''' - Keeps the socket opened
 
* '''-d''' - Means you have specified the ip address as the bind address
 
* '''-d''' - Means you have specified the ip address as the bind address
* '''-u''' - Enables dual stack socket to support both ipv4 and ipv6 for the listening socket, if that is available, you must bind to an ipv6 ip address
 
* '''-z''' - Wait for the data to be sent if any and then close the socket
 
  
 
== Parameters ==
 
== Parameters ==
Line 23: Line 20:
 
* '''<port>''' - The port you want to send to information to, that's your listening port if you create a server.
 
* '''<port>''' - The port you want to send to information to, that's your listening port if you create a server.
 
* '''[numbytes]''' - If -b has been specified, indicates the number of bytes you want to send.
 
* '''[numbytes]''' - If -b has been specified, indicates the number of bytes you want to send.
* '''[text|%var|&binvar]''' - If specified, the message you want to send, can be a binary variable. You don't want to specify that parameter if you create a server.
 
  
 
== Example ==
 
== Example ==
<source lang="mIRC">
 
alias gettime {
 
  ; Set a NULL byte binary variable.
 
  bset &null 1 0
 
  
  ; Open a UDP connection to Time-a.nist.gov = 129.6.15.28
 
  sockudp -k gettime 129.6.15.28 37 &null
 
}
 
  
ON *:UDPREAD:gettime: {
+
== Compatibility ==
  ; Read the reply.
+
Added: mIRC v5.5
  sockread -f &time
 
  
  var %time $bvar(&time,1,$bvar(&time,0))
+
Added On: 08/01/99
  
  ; Convert to binary, remove spaces.
 
  var %bin $regsubex(%time, /(\d+)\s?/g, $base(\1, 10, 2, 8))
 
  
  ; Get the current unix time in decimal system.
+
<small>Note: Individual switches were not taken into consideration.</small>
  var %time = $base(%bin, 2, 10)
 
 
 
  ; Print the time.
 
  echo -ag Currnt Time/Date: $asctime($calc(%time - 2208988800), yyyy-mm-dd hh:nn:ss TT)
 
 
 
  ; Close the socket
 
  sockclose $sockname
 
}
 
</source>
 
 
 
== Compatibility ==
 
{{mIRC compatibility|5.5}}
 
  
 
== See also ==
 
== See also ==
 
* [[List of commands - mIRC|List of commands]]
 
* [[List of commands - mIRC|List of commands]]
 
* [[List of identifiers - mIRC|List of identifiers]]
 
* [[List of identifiers - mIRC|List of identifiers]]
* {{mIRC|on udpread}}
+
* [[on udpread - mIRC|on udpread]]
* {{mIRC|on sockwrite}}
+
* [[on sockwrite - mIRC|on sockwrite]]
* {{mIRC|$sockerr}}
+
* [[$sockerr - Identifiers |$sockerr]]
{{mIRC command list}}
 
  
[[Category:mIRC commands|sockudp command - mIRC]]
+
[[Category:mIRC commands]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)