|
I meet a problem when making a multicast program these days.I first create a multicast receiver program and join a host group, and then i create a multicast sender program to send data to the host group.But the problem is if I send a packet with size larger than 28112 bytes, the receiver would not receiver it and if the size is smaller than 28112 ,it works ok.
I am really confused. Anybody who met similiar problem, please tell me your experience, any information is useful to me.Thanks very much!
To be better, better and better ...
|
|
|
|
|
I have used the hashtable in java but I want to use the same functionality in vc++.
What exactly i want is that I want to use "192.168.2.61"IP's as my keys and Macs "00:50:8D:39:61:E1" as my items. So that I may be able to insert(put) the item(Mac) w.r.t ip(key) in the table and get it back when is needed, so I may be able to manage my routing table.
Please help me.
Reply me soon
|
|
|
|
|
CMapStringToString mYmAcMaP;
mYmAcMaP[_T("192.168.2.61")] = _T("00:50:8D:39:61:E1");
|
|
|
|
|
Hello,
I’m confused about why the following socket code gives me the blue screen of death. The code works when the client is local (on the same machine as the server). When I try the server code with a remote client (on another PC) I always get the BSOD every time after sending a few bytes. The strange thing is that if I put a Sleep command that sleeps for 20 milliseconds before the send command, the server code works. I’m running WIN2000 Professional, Netgear FA311/312 network card and AMD 1.2Ghz CPU.
bool CBlockingSocket::Accept(CBlockingSocket& sConnect, LPSOCKADDR psa)
{
ASSERT(m_hSocket != NULL);
ASSERT(sConnect.m_hSocket == NULL);
int nLengthAddr = sizeof(SOCKADDR);
int iError = 0;
char cErrorMsg[6], strErrorMsg[50];
sConnect.m_hSocket = accept(m_hSocket, psa, &nLengthAddr);
if (sConnect == INVALID_SOCKET)
{
// no exception if the listen was canceled
if ((iError = WSAGetLastError()) != WSAEINTR)
{
cout << "I'm waxing my modem" << endl;
itoa(iError, cErrorMsg, 10);
strcpy(strErrorMsg, "Accept Error: ");
strcat(strErrorMsg, cErrorMsg);
throw strErrorMsg;
}
return FALSE;
}
return TRUE;
}
void CBlockingSocket::Connect(LPCSOCKADDR psa)
{
ASSERT(m_hSocket != NULL);
// should timeout by itself
if (connect(m_hSocket, psa, sizeof(SOCKADDR)) == SOCKET_ERROR)
{
throw "Connect";
}
}
int CBlockingSocket::Write(const char* pch, const int nSize, const int nSecs)
{
int nBytesSent = 0;
int nBytesThisTime = 0;
const char* pch1 = pch;
do
{
nBytesThisTime = Send(pch1, nSize - nBytesSent, nSecs);
nBytesSent += nBytesThisTime;
pch1 += nBytesThisTime;
} while(nBytesSent < nSize);
return nBytesSent;
}
int CBlockingSocket::Send(const char* pch, const int nSize, const int nSecs)
{
ASSERT(m_hSocket != NULL);
// returned value will be less than nSize if client cancels the reading
FD_SET fd = {1, m_hSocket};
TIMEVAL tv = {nSecs, 0};
if (select(0, NULL, &fd, NULL, &tv) == 0)
{
throw "Send timeout";
}
int nBytesSent;
if ((nBytesSent = send(m_hSocket, pch, nSize, 0)) == SOCKET_ERROR)
{
string strError;
char cError[2];
int i = WSAGetLastError();
strError = "Send Error: ";
itoa(i, cError, 10);
strError += cError;
throw strError;
}
return nBytesSent;
}
int main(void)
{
WSADATA wsd;
if (WSAStartup(0x0101, &wsd) != 0)
{
cout << "Unable to start socket\n";
}
CSockAddr saClient;
char* buffer = new char[12];
buffer[11] = '\0';
CBlockingSocket sockListen;
CConnectionSocket sConnect;
CSockAddr saServer(INADDR_ANY, 2112);
sockListen.Create();
sockListen.Bind(saServer);
sockListen.Listen();
strcpy(buffer, "Hello World");
if (!sockListen.Accept(sConnect, saClient))
{
// view or application closed the listing socket
return 0;
}
for (int iii = 0; iii < 100000000; ++iii)
{
sConnect.Write(buffer, 11);
}
}
Any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
You need to change the way you setup your socket set to use with select. The second element of the fd_set structure is an array, not a simple value. Use the following:
fd_set fd;
FD_ZERO(&fd);
FD_SET(m_hSocket, &fd);
if(select(...))
...
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I am trying to insert an ActiveX Control using the resource manager. As a quick test I have tried inserting it into the "help" dialog box from a simple hello world app. Once it is inserted however the dialog box will not appear when I select help from the menue. I added an item to the menue to open my own dialog box and the same thing happens, the dialog box just does not appear. It will appear again if I remove the activeX control from the dialog via the resource editor. Does anyone know what I am doing wrong?
Thank you for any comments.
Mardigin
|
|
|
|
|
Do you call AfxOleInit() in InitInstance (MFC), or AtlAxWinInit in Run (WTL) ?
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I am not entirely sure what the problem was here, but I rebuild the project and it works fine now. Hmm.. I think that I may not have build the correct type of project the first time around. At first I build a Win32 Application, the second time I used the MFC App Wizard. I realize now that the AtiveX Controls must be part of MFC and that explains Why I could not add them to my project.
Thank you for your reply
Mardigin
|
|
|
|
|
I'm trying to create a fast graphics routine in VC++ and I need to be able to pass the hDC of a PictureBox to VC++ from VB, but I don't know how. I will be putting the function in a DLL, and I will access it from VB through API calls. I would rather not get into MFC or creating the windows in C++ because I'm just begginning. I just want to be able to edit each pixel individually with SetPixel API. Any help will be greatly appreciated. Thanks!!
|
|
|
|
|
|
I want to use one of the pains to be the cmd.exe window so that when I call CreateProcess() to spawn cmd.com it uses one of the pains instead of creating a whole new console window. Anyone know if and how that can be done? I tried to set the values of the PROCESS_INFORMATION to the pain's rectangle and the three handles to my window's handles, but that doesn't work.
|
|
|
|
|
it is impossible, i think.
but u can hide cmd window and capture all of its text, then display the text on ur own pane.
createprocess is right to do that. hope useful.
includeh10
|
|
|
|
|
One solution is piping. Here is one reference.
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q190/3/51.asp&NoWebContent=1
Kuphryn
|
|
|
|
|
Hi, I 've experiencing a quite weird problem. I overload new & delete. In new I allocate memory from malloc() and then I add the given pointer to a list. I use an std::list<void*>. So it's sth like that:
<br />
void* operator new(size_t size)<br />
{<br />
void* p = malloc(sizeof(byte)*size);<br />
...<br />
myList.push_back(p);
<br />
return p;<br />
}<br />
However as I 've seen with debug the list in order to create a new node uses the new operator, that comes back to me that I 've overload it! I suppose you can see the eternal recursion. What is weird though is that exactly the same code works perfectly fine in unix using the std::list and the g++ for compiler (in windows I use VC++ .NET).
I 'm open to suggestions, it 's driving me crazy
Thanks, Themis
|
|
|
|
|
This would make sense if you're overloading the global new & delete operators. std::list makes a copy of the items, which would explain the recursion problem. Not sure how GCC would resolve this, are you maybe just overloading it for a single class there?
|
|
|
|
|
I guess what happens is this: std:list uses an allocator object (std::allocator by default) which in VC++ happens to call new for memory allocation. To break the loop, write your own allocator and use it when definining the type myList belongs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I would like to create a MDI project without the caption bar and the border. Is it possible? Also, I would like the child windows to be without Caption and border bar.
Any ideas?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Anyone have trouble building the release version of their MFC project w/ ATL support after it builds and runs just fine in debug mode? If so, what did you do to solve the problem? Thanks again.
Matt (Padawan Learner)
|
|
|
|
|
It might be helpful to tell people what error you get. We are all master psychics, but the guild rules are very strict....
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
We are all master psychics, but the guild rules are very strict
But of course we all knew you'd say that
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I am trying to automate word in an MFC application. I have followed the various tutorials for other office applications. When I try to automate word, what is the same of the header file I need to include. For example I was using excel.h for Excel2002. TIA.
Matt (Padawan Learner)
|
|
|
|
|
If you created the Word classes by importing the type library (msword.olb), the .CPP and .H files will automatically be added to your project via ClassWizard.
|
|
|
|
|
I'm trying to set Terminal font in my CEdti control using the follow code:
[code]
font.CreateFont(8, 0, 0, 0, FW_DONTCARE,
0, 0, 0,
OEM_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH, "Terminal"
);
[/code]
The font chages to some Courier like font and lines is ovelap each other.
But how to get the Terminal font worked?
I did google and this site search but no luck. If I chage Terminal to Courier all seems to wark fine but I need exactly Terminal font which surely installed on my system.
|
|
|
|
|
Oh! When I tried exactly the code I have typed in previous post all works fine!
This site really helps me! )))
|
|
|
|
|
Hi,
I would like to know what is the difference between a child window and a sibling window?
Thanks!
Everything's beautiful if you look at it long enough...
|
|
|
|