<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://spectrum.alioth.net/doc/index.php?action=history&amp;feed=atom&amp;title=Sendto</id>
	<title>Sendto - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://spectrum.alioth.net/doc/index.php?action=history&amp;feed=atom&amp;title=Sendto"/>
	<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Sendto&amp;action=history"/>
	<updated>2026-04-19T12:56:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://spectrum.alioth.net/doc/index.php?title=Sendto&amp;diff=146&amp;oldid=prev</id>
		<title>Winston: New page: '''sendto (IXCALL 0x3E18)''' - send a message via a socket  == Synopsis ==  ''Assembly language''       ld a, (v_sockfd)      ld hl, BUF_SOCKINFO      ld de, BUF_DATA      ld bc, BUF_DATA_...</title>
		<link rel="alternate" type="text/html" href="https://spectrum.alioth.net/doc/index.php?title=Sendto&amp;diff=146&amp;oldid=prev"/>
		<updated>2008-08-16T11:39:13Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;#039;&amp;#039;&amp;#039;sendto (IXCALL 0x3E18)&amp;#039;&amp;#039;&amp;#039; - send a message via a socket  == Synopsis ==  &amp;#039;&amp;#039;Assembly language&amp;#039;&amp;#039;       ld a, (v_sockfd)      ld hl, BUF_SOCKINFO      ld de, BUF_DATA      ld bc, BUF_DATA_...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''sendto (IXCALL 0x3E18)''' - send a message via a socket&lt;br /&gt;
&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
&lt;br /&gt;
''Assembly language''&lt;br /&gt;
&lt;br /&gt;
     ld a, (v_sockfd)&lt;br /&gt;
     ld hl, BUF_SOCKINFO&lt;br /&gt;
     ld de, BUF_DATA&lt;br /&gt;
     ld bc, BUF_DATA_LEN&lt;br /&gt;
     ld ix, SENDTO&lt;br /&gt;
     call IXCALL&lt;br /&gt;
&lt;br /&gt;
''C''&lt;br /&gt;
&lt;br /&gt;
     #include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
     #include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
     int sendto(int sockfd, void *buf, size_t len, int flags, struct sockaddr_in *to, socklen_t tolen);&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The routine '''sendto()''' is used to transmit a message via a socket. Typically, it is used for sending datagrams using a socket of type SOCK_DGRAM, for UDP communication.&lt;br /&gt;
&lt;br /&gt;
The socket descriptor is passed in the ''sockfd'' parameter. The parameter ''buf'' points to a buffer to send, and the length of the data to be sent is specified by the ''len'' parameter. At present, the ''flags'' parameter is unused, and should be set to 0. The ''to'' parameter is a pointer to a struct sockaddr_in, which contains the address (local port, remote port, remote address) for the message being sent, and the length of this structure is passed in the parameter ''tolen''. Since this implementation only handles addresses of type sockaddr_in, the ''tolen'' parameter is not used. However, it is good practise to set the parameter.&lt;br /&gt;
&lt;br /&gt;
The assembly language interface takes the socket descriptor in the A register. The register pair HL contains the address of the socket information block, an 8 byte block specifying address parameters. The DE register pair contains the address of the memory buffer to send, and the BC register pair contains the length of the block of data to send.&lt;br /&gt;
&lt;br /&gt;
The contents of memory that are passed in HL are 8 bytes of address information, formatted as follows:&lt;br /&gt;
&lt;br /&gt;
 bytes 0,1,2,3 - the remote host's IP address&lt;br /&gt;
 bytes 4,5     - the remote host's port number&lt;br /&gt;
 bytes 6,7     - the local host's port number&lt;br /&gt;
&lt;br /&gt;
== Return values ==&lt;br /&gt;
&lt;br /&gt;
On success, the C function returns the number of bytes actually sent, or -1 if the call failed.&lt;br /&gt;
&lt;br /&gt;
The assembly language interface returns the number of bytes actually sent in BC on success. On failure, the carry flag is set and A contains the error code.&lt;br /&gt;
&lt;br /&gt;
[[Category:Spectranet]]&lt;/div&gt;</summary>
		<author><name>Winston</name></author>
	</entry>
</feed>