473,799 Members | 2,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_famil y = AF_UNIX;

strcpy(local.su n_path, "sock");
len = sizeof(local.su n_family) + strlen(local.su n_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_famil y = AF_UNIX;

strcpy(local.su n_path, "sock");

unlink(local.su n_path);

len = sizeof(local.su n_family) + strlen(local.su n_path);

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

listen(sd, 5);

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

printf("%s\n",d ata);

}

Nov 2 '07 #1
1 1346
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.progr ammer 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
3081
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 the properties of a socket WITHOUT closing it and creating a new one? Basically, I need to change the port of a bound socket, but the only way I have found to do this so far is to close the exisitng socket and create a new one. This in itself...
1
7112
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 IOControlCode.KeepAliveValues options. But I didn't found article that explain how to use it.
12
3606
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 utilities that allows you to view them with live rotation in a web browser. Also, it includes a introductory tutorial to POV-Ray.
6
2853
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 I get is Input: and the program quits. I also tried reading this online but I didn't quite get it. What is the diff between sin_addr and sin_addr.s_addr. My understanding is that the latter is the IP address of my machine where as the former is...
2
1612
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 give me.
1
1605
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
1715
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
1088
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 particular domain ......
0
1016
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 valid or not . example:- email id :-xyz@gmail.com password:-1234
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.