When the port number is 0 the system assigns a negative number on the schools server, but a regular >1024 port number on my local Debian system. If you specify a port number it assigns properly on my Debian system but the school server denies permssion. Even if you specify something like 55739 the school server won't give up the port.
When using the program if you specify the negative number returned by the school server all the client programs work fine.
I'm using kernel 2.4.27 and the server is using 2.6.11.
Can anyone tell me possibly why it does this?
Name:
Anonymous2006-04-13 14:56
Can anyone tell me possibly why it does this?
sendPort is signed and ntohs returns an unsigned value.
if the value is higher than 32767, it will be interpreted as negative. make sendPort unsigned to fix it.
Name:
Anonymous2006-04-16 18:58
try using 32 bits u nub
Name:
Anonymous2006-04-29 11:03
The first parameter to socket() is the _protocol_ family (well domain actually but that's basically the same thing these days), not the address family. For portable code, use PF_INET instead. AF_* is for the family field in a sockaddr subtype.
Also, why the hell are you casting length to an unsigned int pointer? Why not declare it to be the correct type in the first place?
Name:
Anonymous2006-04-29 11:59 (sage)
>>4
Most of that code was copied from example files my professor provided. If you have beef, go yell at him.
Name:
Anonymous2006-04-29 16:26 (sage)
>>5
I don't know where to find the professor of Anonymous, but he is a dickwad indeed.
Name:
Anonymous2006-04-29 21:20 (sage)
>>5
Newsflash: Most professors can't write code for shit. That's why they're in acedemia.
I had a teacher very knowledgable in hardware and embedded stuff, he was so specialized he didn't knew there was other languages than C out of his office...
Name:
Anonymous2006-04-30 18:30
>>7
This is a true story. I can tell by some of the words and by having had a few professors in my time.
Seriously, they failed hard. I'll throw a few true stories in:
- This professor had the fame of being the best programming professor. I got a copy of some Pascal exercises made by him. They sucked, this guy managed to make simple things complicated. For example, he was looking for an end of line using two loops, one that scans characters within words and another that loops around it scanning words and newlines.
- Another professor didn't know what a scripting language is. Holy fuck.
- This professor asked me what's this "HT" thing. After a few seconds I realized he meant PHP.
- Another professor wouldn't touch C even if his life depended on it.
Name:
Anonymous2006-04-30 19:37
I have to wonder what kind of universities some of you go too...
Name:
Anonymous2006-05-01 5:35
>>11
Most unis are like this. If you can get into MIT or whatever, great, otherwise you'll be spending 3 years with java.sun.com as your home page, dealing with lecturers who distribute poorly written assignments in msword format.
Name:
Anonymous2006-05-01 5:53
>>12
Man, amerika sure has the best universities in the world!
>>13 >>14
And I'm >>7 and experienced the wonderful education system of several East and West countries. It's all the same: Most professors can't write code for shit. That's why they're in acedemia.
Name:
Anonymous2006-05-01 20:09
>>15
I've been to universities in Canada, Australia, New Zealand, and Germany. My experience does not reflect yours.
Of course, these were all well-known for their CS departments, so my sample is biased.
Name:
Anonymous2006-05-02 4:35
>>16
There are 2 possibilities:
1) you lucked out
2) you haven't noticed
Granted, there are some that do know what they're doing, but for most? Whee!
Name:
Anonymous2006-05-02 8:24
>>17
Agree. I can tell Spanish teachers are the same.
Name:
Anonymous2006-05-03 21:35
Lol undergrads don't know shit about Profs.
Name:
Anonymous2006-05-04 3:36
>>19
Undergrads don't know shit about professors alright, they think professors actually produce good examples of code. Same as Postgrads.
Name:
Anonymous2006-05-04 3:49
I already graduated, and during my time at uni (and of course after it) I always thought professors don't know shit and they produce horrendous code. They have their heads too far up their asses specialized in one little thing which is also usually outdated or unpractical to know about properly coding. I swear I once saw one of them not even indenting their code, I wanted to punch him but I wanted to pass the exam.
Name:
Anonymous2006-05-04 4:11
I had a professor who used this brace style: function(type arg)
{
if(something)
{
doStuff();
}
else
{
dontDoStuff();
}
}Every time he gave out code I had to reformat it before I could even look at it without barfing.
Then again I know a Perl programmer whose boss indents backwards to save space. I won't even try to give an example here, I'll leave it as a thought experiment.
>>23
GNU style puts the brace halfway between the block header and the block body, eg: int main(int argc, char** argv)
{
puts("Hello, RMS!");
return 0;
}
Which is slightly different from the above. The rational for this is to keep everything that's not a function definition away from the first column, to make it easier for automated tools to find them. To which I say: NO GNU!
Name:
Anonymous2006-05-04 7:28
>>25
Does GNU style dictate putting the function names on a line of its own with the return type above?
I like that because it allows me to grep for ^function-name and only find the line that implements the function.
Name:
Anonymous2006-05-04 10:05
>>25
Wow, that's even more braindead. Did the GNAA make a contest for the ugliest indentation?
>>26
Most good editors will allow you to define regular expressions to look for functions, then they'll build a nice list of functions for you.
Name:
Anonymous2006-05-04 11:03
You give the GNAA too much credit.
Name:
Anonymous2006-05-10 11:50
>>26
i don't know about GNU, but this is a strictly enforced standard in BSD code
Name:
Anonymous2006-05-10 12:15
Well I think it looks ugly and a shitty decision to workaround shitty editors which lack features.