You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
67 lines
1.2 KiB
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
|
|
#include <scot/socket.h>
|
|
#include <scot/socket_un.h>
|
|
#include <scot/stream.h>
|
|
#include <scot/exception.h>
|
|
|
|
#include <scot_common.h>
|
|
|
|
|
|
int
|
|
main (int argc, char * argv [])
|
|
{
|
|
excenv_t * ee;
|
|
struct scot_socket * sock;
|
|
char puffer [1024];
|
|
struct scot_stream * sock_stream;
|
|
|
|
atexit (exc_end);
|
|
|
|
TRY
|
|
{
|
|
sock = scot_socket_un_new ("/tmp/socket");
|
|
scot_socket_connect (sock, NULL);
|
|
|
|
sock_stream = (struct scot_stream *) sock;
|
|
|
|
printf ("Client: ");
|
|
while (fgets (puffer, 1024, stdin) != NULL)
|
|
{
|
|
if (send (sock_stream->handle.sock, puffer, strlen (puffer), 0) !=
|
|
strlen (puffer))
|
|
THROW (EXC (EXC_ERROR, errno, "Client: Fehler beim schreiben."));
|
|
|
|
if (strlen (puffer) == 2 && puffer [0] == 'q')
|
|
break;
|
|
printf ("Client: ");
|
|
}
|
|
|
|
scot_socket_free (sock);
|
|
}
|
|
CATCH (ee)
|
|
{
|
|
exception_t *e;
|
|
|
|
while (e = retrive_exception (ee))
|
|
{
|
|
switch (exc_errnum_get (e))
|
|
{
|
|
case SCOT_SOCKET_CONNECT_FAIL:
|
|
scot_socket_free (sock);
|
|
case SCOT_SOCKET_NEW_FAIL:
|
|
break;
|
|
}
|
|
|
|
print_exception (e);
|
|
free_exception (e);
|
|
}
|
|
|
|
free_catched (ee);
|
|
}
|
|
|
|
return 0;
|
|
}
|