Sponsored Content
Full Discussion: Naming a socket
Top Forums Programming Naming a socket Post 302095605 by geester on Wednesday 8th of November 2006 11:17:36 AM
Old 11-08-2006
Naming a socket

Im not very experienced with C so this is probably a basic question. I have a script that opens up 5 sockets, it then runs through a loop and on a given event reconnects to the relevant socket and sends some data. The socket to be reconnected to is kept track of with a 'count' variable. The sockets are named s0,s1,s2 etc. This is the code I have to send the data:

Code:
if (count == 0) write(s0,"some data",9);
if (count == 1) write(s1,"some data",9);
if (count == 2) write(s2,"some data",9);
if (count == 3) write(s3,"some data",9);
if (count == 4) write(s4,"dome data",9);

Instead of this I simply want to use:

write(s+count,"some data",9)

But how do I append the count integer onto the 's'

Thanks, G
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Controller Naming

Hello all, How does the Solaris identifies the controller subscript ? ( like c0txdxs0 or c1txdxsx ?? ) I have a unix box ( Ultra 30) running with 2.5.1. When I connected an external hard disk to the on-board scsi port, it got identified as c0t1dxsx... (... (1 Reply)
Discussion started by: shibz
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. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

4. Programming

which socket should socket option on be set

Hi all, On the server side, one socket is used for listening, the others are used for communicating with the client. My question is: if i want to set option for socket, which socket should be set on? If either can be set, what's the different? Again, what's the different if set option... (1 Reply)
Discussion started by: blademan100
1 Replies

5. Programming

socket function to read a webpage (socket.h)

Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct... #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include... (3 Replies)
Discussion started by: cyler
3 Replies

6. Programming

Error with socket operation on non-socket

Dear Experts, i am compiling my code in suse 4.1 which is compiling fine, but at runtime it is showing me for socket programming error no 88 as i searched in errno.h it is telling me socket operation on non socket, what is the meaning of this , how to deal with this error , please... (1 Reply)
Discussion started by: vin_pll
1 Replies

7. Shell Programming and Scripting

naming columns

i have a file staff.txt with contents tom|25|New York sims|40|London neyo|18|Moscow i want to label the column at the top, my output should be Names|age|city of birth tom|25|New York sims|40|London neyo|18|Moscow (4 Replies)
Discussion started by: blackzinga80
4 Replies

8. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

9. What is on Your Mind?

Humorous naming

Dear all, We've been asked to submit names for our documentation system. It used to be the very dry ISDL (Information Services Documentation Library) The replacement is built on a Wiki-beastie but that doesn't help much with a name. I wondered about an acronym based on CRAFT, so I can... (1 Reply)
Discussion started by: rbatte1
1 Replies

10. Shell Programming and Scripting

Help with naming the file

Hi, I have a folder that contains files abc.txt def.txt ....and so on Inside abc.txt, I have @<TRIPOS>MOLECULE 4|Chelerythrine|abcb11_earlyIdentification_Stronginhib_washed_ligprep|sdf|1|dock Inside def.txt, I have @<TRIPOS>MOLECULE... (6 Replies)
Discussion started by: rossi
6 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_buffer_write_at, ldns_buffer_write_at, ldns_buffer_write, ldns_buffer_write_string_at, ldns_buffer_write_string, ldns_buf- fer_write_u8_at, ldns_buffer_write_u8, ldns_buffer_write_u16_at, ldns_buffer_write_u16, ldns_buffer_read_at, ldns_buffer_read, ldns_buf- fer_read_u8_at, ldns_buffer_read_u8, ldns_buffer_read_u16_at, ldns_buffer_read_u16, ldns_buffer_read_u32_at, ldns_buffer_read_u32- SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> void ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t count); void ldns_buffer_write_at(ldns_buffer *buffer, size_t at, const void *data, size_t count); void ldns_buffer_write(ldns_buffer *buffer, const void *data, size_t count); void ldns_buffer_write_string_at(ldns_buffer *buffer, size_t at, const char *str); void ldns_buffer_write_string(ldns_buffer *buffer, const char *str); void ldns_buffer_write_u8_at(ldns_buffer *buffer, size_t at, uint8_t data); void ldns_buffer_write_u8(ldns_buffer *buffer, uint8_t data); void ldns_buffer_write_u16_at(ldns_buffer *buffer, size_t at, uint16_t data); void ldns_buffer_write_u16(ldns_buffer *buffer, uint16_t data); void ldns_buffer_read_at(ldns_buffer *buffer, size_t at, void *data, size_t count); void ldns_buffer_read(ldns_buffer *buffer, void *data, size_t count); uint8_t ldns_buffer_read_u8_at(ldns_buffer *buffer, size_t at); uint8_t ldns_buffer_read_u8(ldns_buffer *buffer); uint16_t ldns_buffer_read_u16_at(ldns_buffer *buffer, size_t at); uint16_t ldns_buffer_read_u16(ldns_buffer *buffer); uint32_t ldns_buffer_read_u32_at(ldns_buffer *buffer, size_t at); uint32_t ldns_buffer_read_u32(ldns_buffer *buffer); DESCRIPTION
ldns_buffer_write_at() writes the given data to the buffer at the specified position buffer: the buffer at: the position (in number of bytes) to write the data at data: pointer to the data to write to the buffer count: the number of bytes of data to write ldns_buffer_write_at() writes the given data to the buffer at the specified position buffer: the buffer at: the position (in number of bytes) to write the data at data: pointer to the data to write to the buffer count: the number of bytes of data to write ldns_buffer_write() writes count bytes of data to the current position of the buffer buffer: the buffer data: the data to write count: the lenght of the data to write ldns_buffer_write_string_at() copies the given (null-delimited) string to the specified position at the buffer buffer: the buffer at: the position in the buffer str: the string to write ldns_buffer_write_string() copies the given (null-delimited) string to the current position at the buffer buffer: the buffer str: the string to write ldns_buffer_write_u8_at() writes the given byte of data at the given position in the buffer buffer: the buffer at: the position in the buffer data: the 8 bits to write ldns_buffer_write_u8() writes the given byte of data at the current position in the buffer buffer: the buffer data: the 8 bits to write ldns_buffer_write_u16_at() writes the given 2 byte integer at the given position in the buffer buffer: the buffer at: the position in the buffer data: the 16 bits to write ldns_buffer_write_u16() writes the given 2 byte integer at the current position in the buffer buffer: the buffer data: the 16 bits to write ldns_buffer_read_at() copies count bytes of data at the given position to the given data-array buffer: the buffer at: the position in the buffer to start data: buffer to copy to count: the length of the data to copy ldns_buffer_read() copies count bytes of data at the current position to the given data-array buffer: the buffer data: buffer to copy to count: the length of the data to copy ldns_buffer_read_u8_at() returns the byte value at the given position in the buffer buffer: the buffer at: the position in the buffer Returns 1 byte integer ldns_buffer_read_u8() returns the byte value at the current position in the buffer buffer: the buffer Returns 1 byte integer ldns_buffer_read_u16_at() returns the 2-byte integer value at the given position in the buffer buffer: the buffer at: position in the buffer Returns 2 byte integer ldns_buffer_read_u16() returns the 2-byte integer value at the current position in the buffer buffer: the buffer Returns 2 byte integer ldns_buffer_read_u32_at() returns the 4-byte integer value at the given position in the buffer buffer: the buffer at: position in the buffer Returns 4 byte integer ldns_buffer_read_u32() returns the 4-byte integer value at the current position in the buffer buffer: the buffer Returns 4 byte integer AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_buffer. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy