User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 30 Oct 2002, 09:14   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
A little request: cam someone upload their socket C-files?

I can't seem to find them on the internet and I need them for my server thingy.

TY in advance
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 30 Oct 2002, 10:13   #2
Slidey
Registered User
 
Join Date: Mar 2001
Posts: 205
Slidey is an unknown quantity at this point
for a client:

you need to call
socket() and connect(), and at some point you need to make up a sockaddr struct

for the server:

socket(), bind(), listen(), then use accept() to gain a connection..

a basic server:

Code:
int main(int argc, char *argv[])
{
        int sockfd, newfd = 0;
        int sin_size;
        struct sockaddr_in my_addr;
        struct sockaddr_in their_addr;

        if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
                perror("socket");
                exit(1);
        }

        bzero(&my_addr, sizeof(my_addr));
        my_addr.sin_family = AF_INET;         // host byte order
        my_addr.sin_port = htons(PORT);     // short, network byte order
        my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP

        if(bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1){
                perror("bind");
                exit(1);
        }

        if(listen(sockfd, 10) == -1){
                perror("listen");
                exit(1);
        }


        while(1){
                sin_size = sizeof(struct sockaddr_in);
                if((newfd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1){
                        perror("accept");
                        exit(1);
                }
                printf("got connetion from %s\n", inet_ntoa(their_addr.sin_addr));
                close(newfd);
        }

        exit(EXIT_SUCCESS);
}
__________________
#linux - home of idiots

#impulsed - home of genius..?
Slidey is offline   Reply With Quote
Unread 30 Oct 2002, 10:38   #3
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
I actually need the implementation of the socket....
The implementation of listen(), read(), write(), open() etc etc.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 30 Oct 2002, 10:57   #4
dave20
bleh
 
Join Date: Mar 2001
Posts: 11
dave20 is an unknown quantity at this point
http://www.ecst.csuchico.edu/~beej/guide/net/html/

that covers basically most of the aspects of basic C network programming and is very useful as it has quite a few examples.
dave20 is offline   Reply With Quote
Unread 30 Oct 2002, 11:02   #5
Slidey
Registered User
 
Join Date: Mar 2001
Posts: 205
Slidey is an unknown quantity at this point
well surely the bit where it says

Code:
        if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
                perror("socket");
                exit(1);
        }
is the implementation of a socket?

and

Code:
        if(listen(sockfd, 10) == -1){
                perror("listen");
                exit(1);
        }
is the implementation of hte listen function?

go read beej's tutorial and learn not to be so vague
__________________
#linux - home of idiots

#impulsed - home of genius..?
Slidey is offline   Reply With Quote
Unread 30 Oct 2002, 11:24   #6
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Quote:
Originally posted by Slidey

go read beej's tutorial and learn not to be so vague
Sorry =/

I read the tutorial, but it's not what I was looking for.
I think I need the socket.h and socket.c files, not 100% sure tho.

A fact is that I DO NOT HAVE SOCKETS.... I have an ethernet chip, a set of drivers for it, and a simple IP implementation. I need to make a socket interface for it.
I need the code that performs for example the CRC on the packet, that fills the IP datagram with the correct info. I need the code that puts the ports on the right place in the structure. I need the code of "open()" and "close()" so that I can smell those network bytes.

I hope that was a bit less vague...
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 23:24.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018