Newsgroup: it.comp.lang.c
Titolo: Socket in c

Cerco manuali sulla programmazione in C di socket e TCP/IP, sia per
Unix che per Windows o Dos.
Qualcuno ha della manualistica o sa dove recuperarla?, ve ne sarei
molto grato.....
Grazie in anticipo....

 molto grato.....
Per mia fortuna non ho mai usato Windows in vita mia.  Per Unix:
comp.unix.programmer ha una "socket FAQ", cui puoi accedere sul net da
http://www.ibrado.com/sock-faq
 , o via anonymous FTP da
ftp://rtfm.mit.edu/pub/usenet/news.answers/unix-faq/socket
 ; la bibbia
indiscussa sull'argomento e' lo Stevens, "Unix Network Programming",
Prentice-Hall (ISBN: 0-13-949876-1).
-- 
Maurizio Loreti                      
http://wwwcdf.pd.infn.it/~loreti/mlo.html
Un. of Padova, Dept. of Physics - Padova, Italy          
lor...@padova.infn.it

molto grato.....
Si chiama Dennis Cox e ha scritto un tutorial sulla gestione del
TCP/IP tramite Winsock in Borland C++ Builder.
Questo e' un programma scritto in C++ :
//---------------------------------------------------------------------------
#include 
#include 
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    // We should be checking for errors in the code - however I am not
for speeds sake
    SOCKET s, incoming;
    WSADATA wsaData;
    SOCKADDR_IN sockAddr, incomingSockAddr;
    char buffer[2048];
    int length;
    // Load the WINSOCK.DLL and initialize it
    if(WSAStartup(0x0101, &wsaData))
    {
        Application->MessageBox("Could not load WINSOCK.DLL", "ERROR",
MB_OK);
        return;
    }
    // We use SOCK_STREAM for TCP. SOCK_DGRAM is for UDP
    s = socket(PF_INET, SOCK_STREAM, 0);
    // Define the socket address
    sockAddr.sin_family = PF_INET;
    // Port number of HTTP is 80
    sockAddr.sin_port = htons(80);
    // I'll don't care what address - any address will do
    sockAddr.sin_addr.s_addr = INADDR_ANY;
    // associate local address with socket
    bind(s,(SOCKADDR *)&sockAddr, sizeof(SOCKADDR_IN));
    // Listen for an incoming connection
    listen(s, SOMAXCONN); // SOMAXCONN means the maximun reasonable
amount
    while(Button2->Enabled)
    {
        // accept a connection on the socket
        length = sizeof(SOCKADDR_IN);
        incoming = accept(s, (SOCKADDR *)&incomingSockAddr, &length);
        while(length != 0 && Button2->Enabled)
        {
            // receive data from the socket
            length = recv (incoming, buffer, 2048,  0);
            Memo1->Lines->Add(buffer);
            send(incoming, "hello\r\n", 7, 0);
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
    Button2->Enabled = FALSE;
}
//---------------------------------------------------------------------------
Andrea Laforgia

Grazie e mille a tutti siete stati gentilissimi!