/* * Copyright (c) 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include main() { char *s0o = "this is written to socket 0\n"; char *s1o = "this is written to socket 1\n"; char s0i[100]; char s1i[100]; int sv[2]; socketpair(AF_UNIX, SOCK_STREAM, 0, sv); write(sv[0], s0o, strlen(s0o)); write(sv[1], s1o, strlen(s1o)); int n = read(sv[0], s0i, 100); s0i[n] = 0; n = read(sv[1], s1i, 100); s1i[n] = 0; cout << "this is read from socket 0: `" << s0i << flush; cout << "this is read from socket 1: `" << s1i << flush; cout << endl; }