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;
}
parse error
On my local machine I keep getting parse error for my footer. When I put it online, it doesn't show anything.I've searched on google but not found a solution for it. The error message:Parse error:
Deleting pointers froms vector?
Hi. I have a vector filled with pointers and I want to delete the pointers. I could do a loop and do delete on all indexes, but my question is that if I just clear the vector. Are the pointers
SuperCali PHP Event Calendar
does anyone have any experience with the SuperCali PHP Event Calendar? I could use some assistance in writing a custom function for it, anyone ever messed with it before?
Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.Some code runs as perfectly valid code, where i would like PHP to issue a warning / error.I guess this is because of the loose typing of PHP,
PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see when I view source, versus what I want to see … I am having image re-sizing issues that
Probably a simple error...
I'm getting the error -- Parse error: syntax error, unexpected '{' in /home/content/c/s/t/csteffen242/html/staples/event.php on line 46I checked it over and couldn't find anything wrong with an extra
Generate multilayered array from string.
ok so i have a string that looks like this:Code: blog:edit_all,delete_all|users:edit_all,delete_all|settingsand i want to make a code that can take that string and put it in a multi-layered array like
Linked Keywords
I am trying to get a script that makes my predefined keyword converted to links and / or converted to a certain color, size and so on... In one of the other threads Ive posted I got an answer I am a
first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have seen this in many news sites where the news story headline reads like "woman found in obama's
need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requirements:Page A - which resides in a private directory so only he as access to it (this part is set up,