Bad Address

Thread Tools Search this Thread
Special Forums IP Networking Bad Address
# 1  
Old 12-20-2007
Bad Address

I am trying to write a C server code that will handle WWW request from client. i am very new to socket programming. i can very well setup the socket...but when an incomin request comes from a browser, the progrom exits with an error message "Bad address". the following is the code. please do help me at the earliest. thank you.I am woring in USS environment in MVS

#define _OE_SOCKETS
#define _NO_PRAGMA
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include "conv.c"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <xti.h>
int main()
int sd,bindval,listval,csd,counter;
int iNoDelay;
char buf<:50:>;
struct sockaddr_in server,client;
pthread_t tid;
printf("\nsocket abount to be created");
perror(" ");
setsockopt(sd,IPPROTO_TCP,TCP_NODELAY,(char *) &iNoDelay,
printf("\nsocket created with id %d",sd);
bindval=bind(sd,(struct sockeaddr_in *) &server,sizeof(server));
printf("\nbind success with rc=%d",bindval);
perror(" ");
printf("\nlisten done rc=%d",bindval);
printf("\nwaiting for connections");
csd=accept(sd,(struct sockaddr_in *) &client,csd);
perror(" ");
printf("\nconnection accepted rc=%d",csd);
strcpy(buf,"HTTP/1.1 404 NOT FOUND \n \n");
printf("\nwrite performed");
perror(" ");

thank you
# 2  
Old 12-20-2007
Originally Posted by shankarramv
csd=accept(sd,(struct sockaddr_in *) &client,csd);
That looks all wrong.

The last arg should be the address of a socklen_t, and you are also reusing the variable as a file descriptor.

I suggest you compile with maximum warnings, if using gcc use "-Wall -Werror".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies

2. Shell Programming and Scripting

Why I get bad bad substitution when using eval?

Why I get bad replace when using eval? $ map0=( "0" "0000" "0") $ i=0 $ eval echo \${map$i} 0000 $ a=`eval echo \${map$i}` !!!error happens!!! bash: ${map$i}: bad substitution How to resolve it ? Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies

3. Emergency UNIX and Linux Support

Bad Address when adding system call

Hi guys. I have downloaded kernel 2.6.38-5 to add a system call. I did the following steps: 1. I have added my system call to system call table <src folder>/arc/x86/kernel/syscall_table_32.S .long sys_mycall 2. i have added the system cal number in <src... (5 Replies)
Discussion started by: majid.merkava
5 Replies

4. IP Networking

Tracing a MAC address to IP address: Solaris

Hi there I lost connectivity to one of our remote systems and when I checked the messages log I found the following: Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1 Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies

5. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

6. IP Networking

ifconfig: ce401001: bad address

HI All, My interface card has failed.If i am giving the command to uplumb it i am getting an error. ce401001: flags=219040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER,FAILED,CoS> mtu 1500 index 3 inet netmask ffffffc0 broadcast # ifconfig... (2 Replies)
Discussion started by: sag71155
2 Replies

7. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies

8. IP Networking

How to Achive IP address through MAC(Ethernet) address

Hi sir, i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address....... but i'm nt getting that how i can pass the MAC address to Frame........ Please give me an idea for making such program... Thanks & regards Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies

9. Solaris

ifconfig bad address

hi all iam trying to set my eri0 interface but with little luck . when i set the ip using ipconfig i always get "bad adress".. moreover when i use ifconfig eri0 i can notice that the inet is and the netmask 0 i am runnig solaris 9 on sparc . any helpis highly appreciated ... ... (2 Replies)
Discussion started by: ppass
2 Replies

10. Shell Programming and Scripting

Error "Cat Error: Bad Address "

Hi I get an Error when i am trying to edit a file thru shell script. ERROR IS "cat: write error: Bad address." I don't get this error everytime i run the shell script. Any idea ?? Here is the piece of code: echo "Attempting to edit ${ProbeRuleFile}" if then cp... (1 Reply)
Discussion started by: ss_hpov
1 Replies
Login or Register to Ask a Question