Send

From Spectrum
Revision as of 10:27, 16 August 2008 by Winston (talk | contribs) (New page: '''send (HLCALL 0x3E12)''' - send data via a connected socket == Synopsis == ''Assembly language'' ld a, (v_sockfd) ld de, BUFFER_ADDR ld bc, BUFFER_SIZE ld hl, SEND call...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

send (HLCALL 0x3E12) - send data via a connected socket

Synopsis

Assembly language

  ld a, (v_sockfd)
  ld de, BUFFER_ADDR
  ld bc, BUFFER_SIZE
  ld hl, SEND
  call HLCALL

C

  #include <sys/socket.h>
  #include <sys/types.h>
  
  int send(int sockfd, void *buf, size_t len, int flags);

Description

The send() call is used to send data via a connected socket, that has been connected with either the connect or accept calls. The send() call sends the number of bytes specified by the len parameter, from the memory pointed to by buf to the socket specified by sockfd. The flags parameter is currently not used.

The assembly language interface sends the contents of memory pointed to by the DE register pair, with the number of bytes to send specified in the BC register pair. The accumulator contains the socket number.

Return values

On successful return, the C function returns the number of bytes sent. On error, the C function returns -1.

The assembler interface returns the number of bytes sent in the BC register pair. On error, the carry flag is set and the A register contains the error code.