07-28-2010
how can I send and receive data in client server socket programing
char name;
printf ("Welcome to the server \n");
printf ("Enter user name: \n");
scanf ("%c", &name);
how can client send name to server:what should be the code?
int send ( int sid , const char ∗buffer Ptr , int len , int f l a g )
how can client receive ack from server:what should be the code?
int recv ( int sid , char ∗buffer Ptr , int len , int flags )
plz help me
10 More Discussions You Might Find Interesting
1. IP Networking
Requirements:
A server program should read a file and send the message to the client . if the file is not there, then switch to the receive part of the same program and receive any messages from the socket. If no messages to receive then switch to send part of the program to... (2 Replies)
Discussion started by: Rajeshsu
2 Replies
2. Programming
Hi,
Am very new to socket programming.
When we use UDP sockets to communicate between two processess,
will both the client/server socket be able to send/recv ?
meaning can sendto()/ recvfrom() be used on both server and client?
It could be useful even if anybody provide some link on socket... (1 Reply)
Discussion started by: rvan
1 Replies
3. UNIX for Dummies Questions & Answers
I'm new to socket programming. Have a basic doubt.
I have a structure(global) at the server side.
I have two different client connecting to the server. Will the changes made by one client on the structure be visible to the other client when it accesses the same client? I'm creating a STREAM... (3 Replies)
Discussion started by: abc.working
3 Replies
4. Programming
Problem
- Linux Client/Server Socket Application: Preventing Client from quitting on server crash
Hi,
I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64.
I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Discussion started by: varun.nagpaal
2 Replies
5. Shell Programming and Scripting
Hi,
I would like to write a program to receive the GPS data and then send the data via network to other program.
All of the program is not write yet(include host and sender)
All of the server OS is unix or linux
Could you mind to give me some idea to do this?
Thanks so much!
Ken
... (2 Replies)
Discussion started by: kenlok
2 Replies
6. Programming
hei,
i want to enter name and read it by client server socket program after checking name validity put the password and check.if ok than server clirnt say correct other wise incorrect.
below my code:
char name;
printf ("Welcome to the server \n");
printf ("Enter user name: \n");
scanf... (1 Reply)
Discussion started by: saiful_911
1 Replies
7. Post Here to Contact Site Administrators and Moderators
hi,
i am new to socket programming.i have a problem in server.requirement is it should continuosly read the requests from client(sends requests continuously) and after certain delay(i kept der sleep) should send response.
for this i used msgqueues so that after reading it is sending into... (1 Reply)
Discussion started by: chandinisree
1 Replies
8. IP Networking
hi,
i am new to socket programming.i have a problem in server.requirement is it should continuosly read the requests from client(sends requests continuously) and after certain delay(i kept der sleep) should send response.
for this i used msgqueues so that after reading it is sending into... (1 Reply)
Discussion started by: chandinisree
1 Replies
9. Programming
I'm trying to make a "dual/server client" (ipv4,ipv6) with sockets in linux but i don't know how to join both codes. I have a dual client ipv4 and ipv6, but i have problems with the server if you notice the only difference between them it's the AF_INET (pf_inet ipv4, and if_inet6 ipv6) and the port... (3 Replies)
Discussion started by: godna
3 Replies
10. Solaris
Good morning everyone,
I'm looking for some help to retrieve data in a scenario where I might have made a big mistake. I'm hoping to understand what I did wrong.
My system is made of two Solaris 11 Express servers (old free version for evaluation). The first if for data and the second is... (7 Replies)
Discussion started by: rnd
7 Replies
SEND(2) System Calls Manual SEND(2)
NAME
send, sendto, sendmsg - send a message from a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
cc = send(s, msg, len, flags)
int cc, s;
char *msg;
int len, flags;
cc = sendto(s, msg, len, flags, to, tolen)
int cc, s;
char *msg;
int len, flags;
struct sockaddr *to;
int tolen;
cc = sendmsg(s, msg, flags)
int cc, s;
struct msghdr msg[];
int flags;
DESCRIPTION
Send, sendto, and sendmsg are used to transmit a message to another socket. Send may be used only when the socket is in a connected state,
while sendto and sendmsg may be used at any time.
The address of the target is given by to with tolen specifying its size. The length of the message is given by len. If the message is too
long to pass atomically through the underlying protocol, then the error EMSGSIZE is returned, and the message is not transmitted.
No indication of failure to deliver is implicit in a send. Return values of -1 indicate some locally detected errors.
If no messages space is available at the socket to hold the message to be transmitted, then send normally blocks, unless the socket has
been placed in non-blocking I/O mode. The select(2) call may be used to determine when it is possible to send more data.
The flags parameter may include one or more of the following:
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
The flag MSG_OOB is used to send "out-of-band" data on sockets that support this notion (e.g. SOCK_STREAM); the underlying protocol must
also support "out-of-band" data. MSG_DONTROUTE is usually used only by diagnostic or routing programs.
See recv(2) for a description of the msghdr structure.
RETURN VALUE
The call returns the number of characters sent, or -1 if an error occurred.
ERRORS
[EBADF] An invalid descriptor was specified.
[ENOTSOCK] The argument s is not a socket.
[EFAULT] An invalid user space address was specified for a parameter.
[EMSGSIZE] The socket requires that message be sent atomically, and the size of the message to be sent made this impossible.
[EWOULDBLOCK] The socket is marked non-blocking and the requested operation would block.
[ENOBUFS] The system was unable to allocate an internal buffer. The operation may succeed when buffers become available.
[ENOBUFS] The output queue for a network interface was full. This generally indicates that the interface has stopped sending,
but may be caused by transient congestion.
SEE ALSO
fcntl(2), recv(2), select(2), getsockopt(2), socket(2), write(2)
4.2 Berkeley Distribution May 14, 1986 SEND(2)