|
DEFAULT_PORT = 5150
But I tried 4629, but I think it was the same error.
I try to explain again:
When you now explained the INADDR_ANY constant, I think the computer (the server in LAN) doesn't leave the right IP to INADDR_ANY, because when I use a code here from CP I can see currently TCP connections to the computer and then I can see the app server's connection with Local IP 0.0.0.0 and some other IP 0.0.0.0...
So, why I tried to assign the right IP direcly to the varible ( but the ip in the code example isn't the right IP! to be sure it listen on the right server ip.
I'll go see the faq now... thanks if you can help me!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
INADDR_ANY is actually 0.0.0.0, so don't expect to find there the IP of your local machine. What happens is that Winsock treats 0.0.0.0 in a special way, meaning "all of the IPs currently assigned to the local machine". I say "all if the IPs" because a machine can have more than one IP: for instance, if it is conencted to a LAN and also to the Internet via a modem. So, a server bound to INADDR_ANY is prepared to listen to any connect incoming request from any network the local machine is connected to. Hope this helped to clear things up a little.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay, then I see!
But do you have any clue on why it't can't find the server then?
Can it be but why doesn't it finds a server when I call it?... hm..
Well guess you can't help me anymore! But a big thanks for explain the INADDR_ANY constant!
It realy confused me!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
It's hard to say without more info... Have you put the server socket in listening mode with listen ?
I'd say you better formulate a new question to this forum (so that it appears on top of the list) providing more info, and, if possible, some code snippets.
Also, if you have some time spare to read the Winsock FAQ and some tutorial on sockets, I'm sure you'll find the answers to your doubts yourself.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi
currently I'm playing around with Mircosoft's Detours-Library, which makes it possible to detour api calls to my dll. Everything works quite fine...
but when I try to log the buffer sent through the winsock "send()" function the app calling the "send()" command crashes.
Here's a part of the code from my DLL:
int __stdcall MINE_sendto(SOCKET s, const char FAR * buf, int len, int flags, const struct sockaddr FAR * to, int tolen )
{
if(file != NULL)
{
char buffer[128];
sprintf(buffer,"send() called:\r\n%s\r\n",buf);
fwrite(buffer,sizeof(char),strlen(buffer),file);
}
return REAL_sendto(s, buf, len, flags, to, tolen );
}
If I comment out the line "sprintf(buffer..." everything works fine, i.e. the problem must be there, but where is the problem actually?
regards
Gregor
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
sprintf(buffer,"send() called:\r\n%s\r\n",buf);
Is buf is zero-terminated?
--Mike--
My really out-of-date homepage
"Hey, you wanna go to the Espresso Pump and get sugared up on mochas?"
-- Willow Rosenberg
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
that's a good question...doesn't it depend on the app calling the "send()" function?
Is there an easy way to find out whether it is zero-terminated?
And must "buf" be zero-terminated?
questions over questions
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
And must "buf" be zero-terminated?
sprintf(buffer,"send() called:\r\n%s\r\n",buf);
buf is being treated as a string (the %s format), so it had better be zero-terminated. If you can't guarantee this, then you'll need to go by the length parameter and only access that many characters in buf .
--Mike--
My really out-of-date homepage
"Hey, you wanna go to the Espresso Pump and get sugared up on mochas?"
-- Willow Rosenberg
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Michael Dunn wrote:
If you can't guarantee this, then you'll need to go by the length parameter and only access that many characters in buf.
could you please explain what you mean?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
if you have a byte array that is zero terminated you call it a null terminated string and you can use stuff like sprintf, strcpy, strcmp etc. on it.
But if you are simply using a sequence of chars with no NULL at the end some of these functions will give you problems.
That's cause these functions all go character by character till they reach a null. I can even imaginre some code like
while(*src && *dest)
{
//do stuff here
}
Got it now?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Gregor S. wrote:
could you please explain what you mean?
If you are not sure if buf ends with \0, then you must at least know its length to use it. Otherwise, you may try to access out-of-bound elements.
If you know the length of buf, then you can use the following approach:
char *sNewBuf = new char (length + 1);
memcpy (sNewBuf, buf, length);
sNewBuf [length] = '\0';
sprintf(buffer,"send() called:\r\n%s\r\n",sNewBuf);
delete sNewBuf;
This may not be the best way, but it should work!
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
I don't care whether it's the best way
The most important thing is that it works perfect!!!!
Thanks!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Gregor,
Dont forget to correct my code. Here is the fixed one:
char *sNewBuf = new char [length + 1];
memcpy (sNewBuf, buf, length);
sNewBuf [length] = '\0';
sprintf(buffer,"send() called:\r\n%s\r\n",sNewBuf);
delete [] sNewBuf;
Sorry for my carelessness
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
Hmmm, I took a close look at your code and noticed a nasty bug in it. This line:
char *sNewBuf = new char (length + 1);
Should actually be:
char *sNewBuf = new char [length + 1];
Otherwise you end up allocating a pointer to a single character set to the ASCII value corresponding to length + 1.
This also means that the delete statement should be changed to:
delete [] sNewBuf;
Note that the code may actually work as you have it, but your memcpy is overwriting "foreign" memory which may or may not be allocated for other purposes - in other words, you're asking for trouble.
Regards,
Alvaro
|
|
|
|
|
|
I need to parse together a fully formatted Word document programmatically, and fill it with a detailed report. Trouble is a blank Word Doc is 19.0kB. What is all that junk in there? Is there anywhere I can get a list of all the parameters I need to add to the document just to get started on the report? or should I just stick with an RTF file maybe? Please help.
Why not throw away a dime?
I throw away ten pennies all the time.
|
|
|
|
|
Take a look at http://www.wotsit.org/
You can fin't definitions on most file formats there...
BTW, I would go with RTF, it's quite easy
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Greetings,
I was wondering if there is there a way to only allow file previewing done in explorer to preview certain file extensions?
For example lets say I would like to allow html files to preview in file explorer but not wave files?
Thanks in advance!
|
|
|
|
|
|
Hmm, interesting idea, but I still have to leave the files visible for the user to be able
move the files around.
ie: copy a wav from folder 1 to folder 2.
|
|
|
|
|
Hello,
I posted some code yesterday and Nish [BusterBoy] was kind enough to give me a pointer.. I am trying to make a MDI Web browser (CHtmlView). But every time I try to surf to a new url, my app crashes (I have a edit box in the tool bar, when I enter any text into the bar and press enter, it crashes). I am very new to MDI apps and I dont even know if this syntax is correct. Can someone give me some pointers or maybe even tell me how I could re-write this code. Im pretty sure the problem is trying to pass the Navigate2 command to the MDIGetActive().. how can I do the same thing differently?
void CMainFrame::OnNewAddress()
{
CString strAddress;
m_wndDlgBar.GetDlgItem(IDC_E_ADDRESS)->GetWindowText(strAddress);
CHtmlView* pHtm = (CHtmlView*)MDIGetActive();
if(pHtm)
{
pHtm->Navigate2(_T(strAddress),NULL,NULL);
}
}
THANKS!
Rob
|
|
|
|
|
MDIGetActive returns a CMDIChildWnd* , so I think you should replace that line with
CHtmlView* pHtm = (CHtmlView*)(MDIGetActive()->GetActiveView());
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
YOU ROCK!!!!
Thanks a million, I have been beating my head against the wall for the past few days.
Rob
|
|
|
|
|
HELP ME!!!!!! I am designing an MP3 player (like Winamp) and i need some ideas or help on where to get infomation on how to design this. If any one can help me please reply to this or e-mail me at bh_bad@hotmail.com. Thanks.
theBHBAD
|
|
|
|
|
This ist what you want:
http://www.codeproject.com/dialog/skinsyse.asp
modified 12-Sep-18 21:01pm.
|
|
|
|