i am kinda new to socket programming. wrote the below code for a server. but getting the bind error everytime. i even tried changing the port number(currently is 13 daytime) but doesnt work. please suggest.
#include"header.h"
int main(int argc,char **argv)
{
int listenfd,connfd,retbind;
struct sockaddr_in servaddr;
char buff[MAX];
time_t ticks;
if((listenfd=socket(AF_INET,SOCK_STREAM,0))<0)
{
printf("socket error");
exit(1);
}
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family=AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY); //instead of this use
servaddr.sin_port=htons(13);
if((retbind=bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr)))<0)
{
printf("bind error %dn",retbind);
exit(1);
}
listen(listenfd,1024);
for(;
{
connfd=accept(listenfd,(struct sockaddr *) NULL,NULL);
ticks=time(NULL);
snprintf(buff,sizeof(buff),"%srn",ctime(&ticks));
write(connfd,buff,strlen(buff));
close(connfd);
}
return 0;
}
read integers that returns a negative or prints the average
Im trying to finish this homework assignment by tommarow afternoon and I keep getting stuck.
article site help remaining text
Hi all hope you will be fineI am creating a article site in this site i want to put some text on main page and link it via "read more" text from articles page and complete article will be
how can i display php source code snippets ?
I am outputting some pho code .. and I want to display the source code so people can copy and paste it .... not really wanting to use a TEXTAREA box .... any ideas ?
Problem with shopcart code
Hello, I am having a bit of trouble being able to add a product to my shopcart. My mysql database is setup correctly with the tables (User, ShopCart, ShopCartLine, Product, Order, OrderLine,
apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?
Printer configuration
Hi All,
Google Map
I have done Google Map Integration for one my project. But for that we need the "latitude and longitude" for this. How we will find the these values using PHP 5.1.6. In 5.2, we can do it
foreach help.
Hello all,First time I'm attempting to use a foreach statement and was just wondering if my code is correct:Code: $sql = "SELECT email from mail_list where subcribed = \"Y\" ";
Parse Error
Hi Guys,I have a function in my class which returns a string link variable. The problem is it keeps giving me a parse error. See code below followed by error message:Code: function
PHP Surveys
I really would like some advice.If you have a client come to you asking for a survey to be done with 117 questions each has 4 radio button check boxes, and a overall percentage needs to be tallyed up.