[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] UDP sockets i linux



Tak for det. Programmerne var meget behjælpelige, men hvordan ville du gøre det med PF_LOCAL og AF_UNIX?

Esben

Henrik Storner skrev:

In <sslug@sslug> sslug@sslug
(Esben) writes:

Jeg har et problem, da jeg gerne vil bruge en udp socket (AF_UNIX; DGRAM) til to-vejs kommunikation, men for at kunne modtage data, skal bind() kaldes, og den kan ikke kaldes mere end én gang på den samme socketpath.

Nogen der har en løsning?


Jeg har skrevet et par små-programmer til dig.


http://www.hswn.dk/~henrik/udpsockets/socksrv.c er en UDP server.
http://www.hswn.dk/~henrik/udpsockets/sockclient.c er en UDP klient.
Oversættes med "gcc -o socksrv socksrv.c; gcc -o sockclient sockclient.c"

De kan snakke med hinanden. Klienten prompter for en tekst; den sender teksten til serveren som behandler den og sender svar tilbage til klienten.

    $ ./sockclient 127.0.0.1 1923
    Enter message: Dav
    Waiting for response ...
    Got message:
    vaD
    Enter message: Hej med dig
    Waiting for response ...
    Got message:
    gid dem jeH

og i et andet vindue:

    $ ./socksrv 127.0.0.1 1923
    Got message: Dav

Got message: Hej med dig


Henrik




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-10-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *