473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

help in socket programing

Please tell me why the follwing program is not working............
client.c
#include<stdio.h>
#include<sys/socket.h>
#include<sys/un.h>

int main()
{

int sd, cd, len, re;

char data[100];

struct sockaddr_un local, remote;

sd = socket(AF_UNIX, SOCK_STREAM, 0);
local.sun_family = AF_UNIX;

strcpy(local.sun_path, "sock");
len = sizeof(local.sun_family) + strlen(local.sun_path);

re = connect(sd, (struct sockaddr *)&local, len);

scanf("%s",data);
send(cd, data, strlen(data)+1, 0);
}
server.c
#include<stdio.h>
#include<sys/socket.h>
#include<sys/un.h>

int main()
{

int sd, cd, len, re;

char data[100];

struct sockaddr_un local, remote;
sd = socket(AF_UNIX, SOCK_STREAM, 0);

local.sun_family = AF_UNIX;

strcpy(local.sun_path, "sock");

unlink(local.sun_path);

len = sizeof(local.sun_family) + strlen(local.sun_path);

re = bind(sd, (struct sockaddr *)&local, len);

listen(sd, 5);

cd = accept(sd, (struct sockaddr*)&remote, &len);
printf("%s",data);
recv(cd, data, 100, 0);

printf("%s\n",data);

}

Nov 2 '07 #1
1 1325
Clement wrote:
Please tell me why the follwing program is not working............
client.c
#include<stdio.h>
#include<sys/socket.h>
#include<sys/un.h>
There's no support for sockets of any description in standard C. Looks
like you're working in UNIX, so comp.unix.programmer would be the group
I'd recommend.


Brian
Nov 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rolln_Thndr | last post by:
I'm vey new to network programing and have a few rather fundemental questions. I'm creating a very basic UDP proxy server and having a few issues regarding the sockets. Is it possible to change...
1
by: semedao | last post by:
Hi, I want to implement keepalive on connected socket between 2 machines , that can be behind NAT. I saw the SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1) and the...
12
by: Xah Lee | last post by:
Of Interest: Introduction to 3D Graphics Programing http://xahlee.org/3d/index.html Currently, this introduction introduces you to the graphics format of Mathematica, and two Java Applet...
6
by: Sean | last post by:
Hi Everyone, My apologies for a somewhat dump question but I am really stuck. I have been working on this code for two days straight I am dont know what is wrong with it. when I run the code, All...
2
by: sengpg345 | last post by:
hi everybody. i have a project in colage for messanger but i haven't idea of socket programing in c#.net . so plz give me the guidence i socket programing. if u have row matirial or tutorial then...
1
by: molaie | last post by:
hello I need a source code program student with languge socket programing with java that: 1- for a car parking 2-that keep number enter & exit cars 3-and report no 2 4-and login thanks
1
by: kavir | last post by:
hello I need a source code program(socket programing with java) that: 1- for a car parking 2-send&save car details to server DB 3-Enter & exit & perice 4-report 5-login
1
by: avinashibs | last post by:
using socket :- how i use the socket for connecting the domain server, e,g :- i have an account on gmail emailid :- xyx@gmail.com pass:- 1354 how i will check my account is exit on that...
0
by: avinashibs | last post by:
how to connect the domain server using socket programing ? actually i have a userid , password . that userid and password go through the server then it will check the email id and password is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.