Sponsored Content
Top Forums Programming help with socket programming in c Post 302410110 by Franklin52 on Sunday 4th of April 2010 04:26:58 PM
Old 04-04-2010
Try something like this after the accept call:

Code:
socklen_t address_length;
int rval;

address_length = sizeof (serverAddr);
rval = getpeername (clientfd, &serverAddr, &address_length);
assert (rval == 0);

printf (“connection accepted from %s\n”, inet_ntoa (serverAddr.sin_addr));


Last edited by Franklin52; 04-04-2010 at 06:14 PM.. Reason: Typo's
 

10 More Discussions You Might Find Interesting

1. Programming

Socket Programming

Dear Reader, Is there any way to check up socket status other than 'netstatus ' Thanks in advance, (1 Reply)
Discussion started by: joseph_shibu
1 Replies

2. Programming

Socket Programming socket

Hello, I actually try to make client-server program. I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error : I'm just using this simple code : and I get the same error if I use : If someone can help me, Thanks (2 Replies)
Discussion started by: soshell
2 Replies

3. Programming

Need Help Regarding Socket Programming

Can anyone plz me. I need a sample code for the following description. Its urgent. It is C/Socket program with the following descriptions: NAME coreadServer - Concurrent Readers Server. coreadClient - Concurrent Readers Client. SYNOPSIS coreadServer <OutputFile> coreadClient <n>... (1 Reply)
Discussion started by: priya.vmr
1 Replies

4. IP Networking

socket programming

my system is a stand alone system... i want to try doing socket porgramming..ihave heard that this is usually done during testing... how can i do that....? (6 Replies)
Discussion started by: damn_bkb
6 Replies

5. IP Networking

socket programming

Hello Everyone Iam working on tcp/ip programming.with some time interval server has to send data.client has to close the connection and to open the connection between the time interval.this is the scenario when iam closing the connection in client side the connection terminates.how to... (1 Reply)
Discussion started by: sureshvaikuntam
1 Replies

6. Programming

help regarding socket programming

i m using sockets for setting up a connection between a server and a client. When the clients gets connected to the server, its ip is conveyed to the server through one of the predefined structures in c library... i save this ip address in an array....1st client's ip address goes to the zeroth... (1 Reply)
Discussion started by: abmxla007
1 Replies

7. UNIX for Advanced & Expert Users

socket programming

can we send udp message to a destination ip address .. without having an ip address configured in our machine using recvfrom ? (2 Replies)
Discussion started by: Gopi Krishna P
2 Replies

8. UNIX for Dummies Questions & Answers

hi i need help with socket programming

in socket programming how can i : Create for example 3 blank files, namely: server, client, network •Server: act as servers/provider, will receive all requests from different client •Client: requesters •Network: middle-layer of communication between server & client any tips or... (6 Replies)
Discussion started by: kedah160
6 Replies

9. Programming

Socket programming

Hi everyone, I'm new to this forum. I'm working on new project for last few days and this forum already helped me on couple of occasions. I don't have any prior experience with network programming so I'll appreciate any advise given. I'm trying to do the following: 1. open user... (2 Replies)
Discussion started by: _thomas
2 Replies

10. Programming

socket programming

how to include socket.h in visual studio 2005.. (2 Replies)
Discussion started by: asd123
2 Replies
Xau(3X) 																   Xau(3X)

NAME
Xau, XauFileName, XauReadAuth, XauLockAuth, XauUnlockAuth, XauWriteAuth, XauGetAuthByAddr, XauGetBestAuthByAddr - X authority database rou- tines SYNOPSIS
#include <X11/Xauth.h> typedef struct xauth { unsigned short family; unsigned short address_length; char *address; unsigned short number_length; char *number; unsigned short name_length; char *name; unsigned short data_length; char *data; } Xauth; char *XauFileName() Xauth *XauReadAuth (auth_file) FILE *auth_file; int XauWriteAuth (auth_file, auth) FILE *auth_file; Xauth *auth; Xauth *XauGetAuthByAddr (family, address_length, address, number_length, number) unsigned short family; unsigned short address_length; char *address; unsigned short number_length; char *number; Xauth *XauGetBestAuthByAddr (family, address_length, address, number_length, number, types_length, types, type_lengths) unsigned short family; unsigned short address_length; char *address; unsigned short number_length; char *number; int types_length; char **types; int *type_lengths; int XauLockAuth (file_name, retries, timeout, dead) char *file_name; int retries; int timeout; long dead; int XauUnlockAuth (file_name) char *file_name; XauDisposeAuth (auth) Xauth *auth; DESCRIPTION
XauFileName generates the default authorization file name by first checking the XAUTHORITY environment variable if set, else it returns $HOME/.Xauthority. This name is statically allocated and should not be freed. XauReadAuth reads the next entry from auth_file. The entry is not statically allocated and should be freed by calling XauDisposeAuth. XuWriteAuth writes an authorization entry to auth_file. It returns 1 on success, 0 on failure. XauGetAuthByAddr searches for an entry which matches the given network address/display number pair. The entry is not statically allocated and should be freed by calling XauDisposeAuth. XauGetBestAuthByAddr is similar to XauGetAuthByAddr, except that a list of acceptable authentication methods is specified. Xau will choose the file entry which matches the earliest entry in this list (for example, the most secure authentication method). The types argument is an array of strings, one string for each authentication method. types_length specifies how many elements are in the types array. types_lengths is an array of integers representing the length of each string. XauLockAuth does the work necessary to synchronously update an authorization file. First it makes two file names, one with -c appended to file_name, the other with -l appended. If the -c file already exists and is more than dead seconds old, XauLockAuth removes it and the associated -l file. To prevent possible synchronization troubles with NFS, a dead value of zero forces the files to be removed. XauLock- Auth makes retries attempts to create and link the file names, pausing timeout seconds between each attempt. XauLockAuth returns a collec- tion of values depending on the results: A system error occurred, either a file_name which is too long, or an unexpected failure from a system call. errno may prove useful. gretries attempts failed. The lock succeeded. XauUnlockAuth undoes the work of XauLockAuth by unlinking both the -c and -l file names. XauDisposeAuth frees storage allocated to hold an authorization entry. SEE ALSO
xauth(1X), xdm(1X) AUTHOR
Keith Packard, MIT X Consortium Xau(3X)
All times are GMT -4. The time now is 05:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy