LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-10-2008, 05:09 AM   #1
smartgupta
Member
 
Registered: Sep 2008
Posts: 81

Rep: Reputation: 15
ld: fatal: Symbol referencing errors. No output written to server


Hi,

I am working with Solaris 5.9 and I am newbie in Socket programming and I stated working with socket programming and I copyed a simple client & server program from a website which I am giving below--

Quote:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

void error(char *msg)
{
perror(msg);
exit(1);
}

int main(int argc, char *argv[])
{
int sockfd, newsockfd, portno, clilen;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
int n;
if (argc < 2) {
fprintf(stderr,"ERROR, no port provided\n");
exit(1);
}
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
bzero((char *) &serv_addr, sizeof(serv_addr));
portno = atoi(argv[1]);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
error("ERROR on binding");
listen(sockfd,5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
if (newsockfd < 0)
error("ERROR on accept");
bzero(buffer,256);
n = read(newsockfd,buffer,255);
if (n < 0) error("ERROR reading from socket");
printf("Here is the message: %s\n",buffer);
n = write(newsockfd,"I got your message",18);
if (n < 0) error("ERROR writing to socket");
return 0;
}

when I am compiling these files.I am getting the error--

Quote:
# gcc server.c -o server
Undefined first referenced
symbol in file
socket /var/tmp//ccmoWk0x.o
accept /var/tmp//ccmoWk0x.o
bind /var/tmp//ccmoWk0x.o
listen /var/tmp//ccmoWk0x.o
ld: fatal: Symbol referencing errors. No output written to server
collect2: ld returned 1 exit status
Please Help me to solve it

Thanks in Advance ....

Last edited by smartgupta; 10-10-2008 at 05:18 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fatal error - grub cant be written to hd0 PlaneCharlie Linux - Newbie 2 12-02-2007 12:04 AM
fatal errors loading x server htamayo Debian 2 09-25-2007 04:48 PM
Symbol referencing errors compilg on Solaris ritika Solaris / OpenSolaris 1 06-09-2007 03:33 PM
debian won't start from hd, and x server fatal errors ppcthug Linux - Newbie 28 02-10-2005 12:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration