aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/net/msgport.h
blob: f7817e4f9f0f732e8890124eb1e2cc170af37734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Portable network messaging routines.
 * $Id$
 * Copyright (c) 1997 by Tycho Softworks.
 * For conditions of distribution and reuse see product license.
 */

#ifndef	__NET_MSGPORT_H__
#define	__NET_MSGPORT_H__

#ifndef	__NET_SOCKET_H__
#include <net/socket.h>
#endif

typedef	struct
{
	union
	{
		struct	sockaddr_in	addr;
		long	len;
	}	header;
	ushort	sequence;
	uchar	body[ EMPTY ];
}	SOCKMSG;

/*	msgport control options */

enum
{
	MSGPORT_TIMEOUT
};

#define	attach_tcp(host, port)	getsocket(host, port, SOCK_STREAM)
#define	attach_udp(host, port)	getsocket(host, port, SOCK_DGRAM)

#ifdef	__NAMESPACE
#define	create_msgport	__NAMESPACE(create_msgport)
#define	send_msgport	__NAMESPACE(send_msgport)
#define	recv_msgport	__NAMESPACE(recv_msgport)
#define	reply_msgport	__NAMESPACE(reply_msgport)
#endif

SOCKET	create_msgport(char *mask, int port, int backlog);
size_t	send_msgport(SOCKET so, SOCKMSG *buf, size_t len, bool inc);
size_t	recv_msgport(SOCKET so, SOCKMSG *buf, size_t maxlen, bool any);
size_t	reply_msgport(SOCKET so, SOCKMSG *buf, SOCKMSG *org, size_t len);
#endif