connect() parameters or maybe something else.


 
Thread Tools Search this Thread
Top Forums Programming connect() parameters or maybe something else.
# 1  
Old 05-15-2002
Question connect() parameters or maybe something else.

I'm having trouble when running a program that uses the connect(). I keep receiving errno: 22. Below is the code that I am using.

Do I have the variables set up correctly?

Am I passing the correct parameters?

I have been searching for source code on the connect function but haven't found any. IF you know of some posted on the net I would really appreciate it.

-------------------------------------------------------------------------
int read_sold(char rxfile[], char message[])
{
int i, rc, s;
char hostname[64];
char readbuff[MAXREAD];
struct sockaddr_in sin;
struct sockaddr const fin;

memset(readbuff, 0, MAXREAD);
/*
*** Get TCP address and socket
*/
for (i = 0; i < 3; i++){
if (tcpaddress(&s, POSTORXPORT, &sin, (sizeof(sin)), message) == 0)
break;
if (i == 2) return -1;
}

/*
*** Try to connect to the address
*/
for (i = 0; i < 3; i++) {
if (connect(s, &fin, sizeof(fin)) < 0) {
if (i == 2) {
sprintf(message, "Client CONNECT failed: errno = %d",
errno);

-------------------------------------------------------------------------
# 2  
Old 05-15-2002
No, that's all wrong. s has to be a socket to start with. That is, it should have been returned by a call to socket(). And fin needs to have the ip address and port number in it.

Rather than looking at the source code for connect(), you might want to look for a network programming tutorial.

Here is one tutorial.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Connect direct - SFTP - List of servers that I can connect

Greetings Experts, I am working for a bank client and have a question on connect-direct and SFTP. We are using Linux RedHat servers. We use connect-direct to transfer (NDM) files from one server to another server. At times, we manually transfer the files using SFTP from one server to another... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. Cybersecurity

When i start CSF i cant connect VPS or download any data into it It appears i cant connect Linux VP?

It appears i cant connect linux VPS server via SSH or i cant SCP any file to it and i cant wget any file TO it (from inside it) while CSF (Config Server Firewall, LFD is running. Just after isntall in default configuration and after changing TESTING mode to LIVE mode. Trying to wget & install... (1 Reply)
Discussion started by: postcd
1 Replies

3. AIX

AIX Remote Connect Fail With “No more multiple IP addresses to connect” Error

We have a production server at a client site running AIX. And recently when users are trying to connect to it via telnet, it prompts "No more multiple IP addresses to connect". Can I know what does this error mean? and how to rectify this? Thanks. (2 Replies)
Discussion started by: a_sim
2 Replies

4. Shell Programming and Scripting

Getting parameters

Hi, I have 2 scripts one master.sh and child.sh. The master runs on a separate server and pushes the child script to the desginated server and runs it.The child script configures the designated server for our day to day use and it has lot of interactive questions which help the... (4 Replies)
Discussion started by: a12ka4
4 Replies

5. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

6. Shell Programming and Scripting

Get Options and Parameters

Hi there. Could someone explain how do i get the options separated from the arguments. My problem is that i have a lot of options and in all of those options i need to have the parameters available to use in that option and all the others. How can i take the arguments before i cycle throw the... (4 Replies)
Discussion started by: KitFisto
4 Replies

7. Shell Programming and Scripting

More than nine parameters

Hi, please tell me the systax for passing 11 variables(including 4compulsory variables) in shell program. ORA_USERPASS=`echo $1` USERID=`echo $2` USERNAME=`echo $3` REQUESTID=`echo $4` P5=`echo $5` P6=`echo $6` P7=`echo $7` P8=`echo $8` P9=`echo $9` shift P10=`echo $9` shift... (3 Replies)
Discussion started by: anitha126
3 Replies

8. Shell Programming and Scripting

parameters

i'm supposed to come up with a script that -accepts a directory as an optional command line parameter -display an error message and terminates if more than one parameter is provided -use the current directory if no parameter is provided -displays an error message and terminates if the provided... (4 Replies)
Discussion started by: jaay
4 Replies

9. Shell Programming and Scripting

parameters

I have a script that needs to check if the given parameters are a combination of 0123456789 and not a word or another irelevant character.please help (6 Replies)
Discussion started by: aekaramg20
6 Replies

10. Shell Programming and Scripting

Need Parameters Help.

I can test for one parameter but anything more then that and I get an Error. I forgot I run this batch in a shell #!/bin/sh ------------------------------------------------------------------------- Write a batch program that accepts a keyword as a parameter and finds all the files... (3 Replies)
Discussion started by: james2006
3 Replies
Login or Register to Ask a Question