Advertisement

WinSuck, can only send a char* ?

Started by September 12, 2003 01:03 PM
51 comments, last by Wickeeed 21 years, 4 months ago
"Hmmm, what makes you assume TCP?"

He's using TCP Winsock commands. Select is used to process multiple socket connections which UDP doesn't use. And he's a newbie.

"I was assuming UDP myself, simply because it's the most common protocol for games."

TCP is sufficient for any type of game when just starting. You'd only use UDP if you don't need guarenteed messaging or think you can implement it better than TCP/IP. Again, just reading his source code would make it obvious he's using TCP.

If he were to use UDP he'd just have more problems then he's ready to deal with. You use TCP to make sure everything works and then go to UDP for things you think can get away with it.

Ben


[ IcarusIndie.com | recycledrussianbrides.com | Got Linux? ]


Will Post For Food

[edited by - KalvinB on September 15, 2003 7:19:47 PM]
quote:
Original post by RonHiler
quote:
Original post by Wickeeed
hmm, can you guys say me what i did wrong ????
for (int i=1;i==1;i++) {
[...........]
return pos;
}


This loop never runs, you immediately drop to the return (you set i=1, then check for i==1 which it does, so you drop). Not exactly sure what this for loop is for But whyever it''s there, you never get into the interesting code.




Wow. At least how a for loop works before you try to criticise others.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

Advertisement
quote:
Original post by benjamin bunny
Wow. At least how a for loop works before you try to criticise others.


Wow, WTF are you talking about? I know exactly how a for loop works, thank you very much, and I know that loop never executes. Maybe *you* ought to look at the loop a little more before you pipe in about how I need to learn how to use for loops. Jeez. And who was criticizing? I *think* I was trying to help.

quote:
Original post by KalvinB
He''s using TCP Winsock commands. Select is used to process multiple socket connections which UDP doesn''t use.

Yeah, you''re right, fair enough. I don''t use that particular WinSock model in practice, so I missed that finer point

quote:

If he were to use UDP he''d just have more problems then he''s ready to deal with.

You think? I think the problems are different, not worse or easier, just different. TCP has it''s own set of issues, as you mentioned. I don''t have any more problems getting around UDPs quirks than I do TCPs.
Creation is an act of sheer will
i really think this for loop runs once=)
"I think the problems are different, not worse or easier"

Please. Missing packets are the worst problem you can possibly deal with when doing networking coding. It makes problems appear random. When bugs are random they''re far harder to fix no matter what they are. Coding to consider nonguarenteed data is also a nightmare especially for beginners.

Any problems you may have with TCP are going to be easily reproducable and always be your source code''s fault which narrows down what you need to consider significantly.

"I know exactly how a for loop works"

I don''t think you do, Trebek...

Course this is probably just a result of you making assumptions and criticizing people''s code without actually reading their code. It''s very impolite.

Ben


[ IcarusIndie.com | recycledrussianbrides.com | Got Linux? ]


Will Post For Food
Okay, you guys just made me think I am losing it

So I tested this

for (int i=1;i==1;i++) {
OutputDebugString("Testing");
}

And the damn thing actually does run once! So I officially offer an apology to bunny for being an ass. Aparently I do not know how for loops work, heh. But it makes no sense to me at all. The way I see it, that loop shouldn''t run. WTF? Someone explain to me why that runs.
Creation is an act of sheer will
Advertisement
quote:
Original post by RonHiler
Someone explain to me why that runs.
It repeats while the condition i==1 is true, rather than until it''s true.
Sigh.

Thanks for clearing that up, Beer. Yes, now I feel stupid. I'm so stuck in the mindset (i=x; i less than y, i++) that the == threw me. I've never seen that done before. Fairly pointless in any case.

Ben, I'm sorry I misread your code. It's not as fragile as I thought it was at first. My bad. Wick, use his code as a template, it's fine. I guess I see your point about UDP bugs showing up randomly. In my server I can simulate lag and dropped packets (something I added somewhat recently), and I can cause those sorts of bugs to happen pretty reliably by just setting a large lag value and running through the connection sequence a few times, so it's not so much an issue for me anymore. I'd be much more afraid of having to deal with the TCP stream than UDP packets at this point

I should just shut up. This is what happens when I try to help out. I must be having an off day. While I think I've gotten to a point where I know WinSock *pretty* well, and have something to offer in that area, sometimes I put my foot in my mouth

[edit: how do you get the dratted less than sign without the page thinking it's a HTML tag. Drat it. Jeez I'm having a bad day! ]

[edited by - RonHiler on September 15, 2003 9:21:46 PM]
Creation is an act of sheer will
But, hey, at least you know how a for loop works now

quote:
So I officially offer an apology to bunny for being an ass.

Apology accepted

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

hurry up and help this guy out, can i need to know how to do it to... currently i have this code.
server///////////////////
struct turret{
int x;
int y;
};
turret turret1;
char* Pointer=((char*)&turret1);
recv(sListen, Pointer, sizeof(turret), 0);
turret1= *((turret*)Pointer);

printf("%d",turret1.x);
printf("%d",turret1.y);

client///////////////////////
struct turret{
int x;
int y;
};
turret turret1;
turret1.x=5;
turret1.y=6;
send(s, ((char*)&turret1), sizeof(turret1), 0);

the client connects properly and closes but when i output the values it sent me, it is some huge negative number

This topic is closed to new replies.

Advertisement