Hello all,
I am getting a very strange error in my code :( I am writing a server application in C, to send and receive UDP packets to/from a client. Right now, im just running a loop in which the server receives packets using recvfrom() however.... the function seems to block and everytime I send it something, it sets errno to "resource temporarily unavailable" which is strange, cause it blocks until I send something, meaning that it knows something came no? However, recvfrom always returns -1 This is how I initialized the socket:
//struct timeval tv;
if((s = socket(AF_INET, SOCK_DGRAM, 0))==-1)
return 0;
bzero(&si_me,sizeof(si_me));
si_me.sin_family = AF_INET;
si_me.sin_port = htons(PORT);
si_me.sin_addr.s_addr = htonl(INADDR_ANY);
/*** Set socket timeout ***
tv.tv_sec = 1;
tv.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
{
printf("Couldn't set socket timeoutn");
return 0;
}*/
if(bind(s,(struct sockaddr*) &si_me, sizeof(si_me))==-1)
return 0;
return 1;
and then I ran:
do
{
done = recvData();
printf("Received %d n", done);
}while(done == 0);
with recvData() being:
int recvData(void)
{
if (recvfrom(s, (char*)&buf, UDP_BUFFER_LEN, 0, (struct sockaddr*) &si_other_comp, &slen)==-1)
{
printf("Couldn't read socket (%s)n",strerror(errno));
return 0;
}
return 1;
}
so, program does nothing until it gets a packet, then says it cant read it and then continues doing nothing until it gets another packet.... any ideas?
Help with syntax
Hi all!The $bridge variable is not getting passed while it is contained in the line below:Maybe I don't have the right brackets around it? I want the result to say Bridge1I think it's because its a
Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .I don't understand why this is not working:/*everything above here is working*/ $session = mysql_fetch_array($session_query); $type =
limitations on array_unique()
Does any one know what/how imitations are applied to array_unique? I have an issue where no matter how big (as in over this limit) the array is array_unique always returns an array with 32768
Storing Values taken from a DB...
Using this code it will generate a short list from my database <?phpmysql_connect('localhost','root','');mysql_select_db("clients");$fname = $_POST['firstname'];$SQL = "SELECT *
reading partial code from external site
Hi,I am trying to write a script for my website to get an article from an external website. The external website has the article in a set of tags <roottag> &
elseif help!
OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and so far it's been quite smooth. However whilst trying to change an aspect of the game from giving the
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and then decoded. For security and later readability.
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a sessionCode: <?phpinclude_once 'Connect.php';if (!is_authed()) { die ('You are not
[function.file]: failed to open stream: No such file or directory
Okay I wrote this little script to upload a csv file that is located on my webhosts server to a mysql database. Something is wrong because I am getting the following error:Warning:
FROM_UNIXTIME($phpdate);
Hello, I tried to use this : $date = FROM_UNIXTIME($phpdate); ANd I was told that FROM_UNIXTIME() is an 'unidentified function'. Any ideas why this might be? I've used it before with no problems.