From Spectrum
Jump to navigation Jump to search

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


Assembly language

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


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


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.