|
I'm trying to create a server which accepts client connections.
....
Address.sin_family = AF_INET;
Address.sin_port = htons(1212);
Address.sin_addr.s_addr = htonl(INADDR_ANY);
IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address));
IntReturn = listen(Listen, 10);
IntReturn = sizeof(RemoteAddress);
Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn);
...
Clients from any! ip can connect to my server on port 1212..
My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ?
I thought about changing this line
Address.sin_addr.s_addr = htonl(INADDR_ANY);
to
Address.sin_addr.s_addr = inet_addr("10.0.0.105");
but this does not work, am I doing something wrong?
Thanks
|
|
|
|
|
Use a firewall. Winsock doesn't support connection filtering.
|
|
|
|
|
Well, thats not an option, since I'm using it on a LAN.
|
|
|
|
|
Get IP from the connected client. Check if the IP is an accepted IP and if it's an accepted/allowed IP then start sending datta etc. if not, just disconnect the socket.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hello
Does anyone knows a way to let CHtmlView open HTML pages with pictures in the TIFF format?
Thank you in advance
|
|
|
|
|
Hello
Please, help me!
I need a way to place a TIFF picture in the CHtmlView.
Does anyone know how to let CHtmlView to decode TIFFs?
Even a way to place picture code in BMP or JPG format into the WebBrowsers object model would help.
I think it can be done using IHTMLDocument or other similar interface, but could not find how
Thank you in advance.
|
|
|
|
|
I need to use truetype fonts in a drawing application; in the files generated
by this application, the fonts used are identified not by their font name but by a unique number. I could generate myself arbitrary ID's ans save the associations
ID --> Font name in a separate file.
But of course it would be better if Windows could give me a ID guaranteed to be unique
for each truetype font.
In MSDN i found the structure EXTLOGFONT, which has a member elfMatch :
"A unique identifier for an enumerated font. This will be filled in by the graphics device interface (GDI) upon font enumeration."
Is seems to be what i'm looking for (but not so sure : do these ID change at each
font enumeration ?)
Problem : in MSDN I can't find a function which would output this structure.
|
|
|
|
|
You can not rely on the IDs being unique. They are only unique internally to the running application and that number could be (will be) different every time.
|
|
|
|
|
Thanks. However i would like to experiment ...
Can you tell me how to get that structure ?
|
|
|
|
|
When I am setting up a listener socket, I found that if I use LOCALHOST with inet_addr, that socket can only accept connections from the local machine as indicated in 1) in the following code. However, if I use the machine name, I can accept connections from anywhere but the local machine, as indicated in 2). My question is, is there a way to set up a listener socket that can accept client connections from anywhere including the local machine? Any help will be appreciated.
if ((phostent_far_Hostent = (struct hostent far*)gethostbyname(getenv("COMPUTERNAME"))) == NULL)
{
return INVALID_SOCKET;
}
ZeroMemory((char*)&sockaddr_in_SockAddr, sizeof(sockaddr_in_SockAddr));
1) sockaddr_in_SockAddr.sin_addr.s_addr = inet_addr(LOCALHOST);
2) CopyMemory((char*)&sockaddr_in_SockAddr.sin_addr, phostent_far_Hostent->h_addr, phostent_far_Hostent->h_length);
sockaddr_in_SockAddr.sin_family = phostent_far_Hostent->h_addrtype;
sockaddr_in_SockAddr.sin_port = htons(int_Port_F);
int_SockAddrStructLen = sizeof (sockaddr_in_SockAddr);
if ((SOCKET_Socket = socket(AF_INET, SOCK_STREAM, 0)) < 1)
{
return INVALID_SOCKET;
}
if (bind(SOCKET_Socket, (struct sockaddr*)&sockaddr_in_SockAddr, sizeof sockaddr_in_SockAddr) != 0)
{
closesocket(SOCKET_Socket);
return INVALID_SOCKET;
}
|
|
|
|
|
Your observations are correct. You asked to accept on 127.0.0.1 (localhost), or on a.b.c.d (machine external IP address).
"If an application does not care what local address is assigned, specify the manifest constant value ADDR_ANY for the sa_data member of the name parameter. This allows the underlying service provider to use any appropriate network address, potentially simplifying application programming in the presence of multihomed hosts (that is, hosts that have more than one network interface and address). "
Check out "bind" in your help, You'll find if you leave the address as 0.0.0.0 it should do what you want.
Steve S
|
|
|
|
|
I want to set align for each column in my listview
so I get handle of header control of listview then
use SetItem member function of CHeaderCtrl to do this.
About Align => ok, I got it but I lost all caption
(text) in each column header (no text in headers)
if I use only hdi.mask = HDI_TEXT; >> my texts will
not disappear
What I need to do to set align for each column and
all text is still appear
/////////////////////////////////////////////////
#define LEFT 1
#define CENTER 2
#define RIGHT 3
MyListViewCtrl m_ListCtrl;
m_ListCtrl.cColumnMax = 4;
m_ListCtrl.InsertColumn (0, "#");//left-default
m_ListCtrl.InsertColumn (1, "ID");//left
m_ListCtrl.rgcAlign[1]=1;
m_ListCtrl.InsertColumn (2, "Name");//center
m_ListCtrl.rgcAlign[2]=2;
m_ListCtrl.InsertColumn (3, "Cost");//right
m_ListCtrl.rgcAlign[3]=3;
m_ListCtrl.SetAlign();//set align for all column
////////////////////////////////////////////
void MyListViewCtrl::SetAlign()
{
CHeaderCtrl* pHeader = GetHeaderCtrl( );
HDITEM hdi;
for (int i=0; i<ccolumnmax; i++)=""
="" {
="" char="" buffer[256];="" ="";="" hdi.mask="HDI_TEXT|HDI_FORMAT;
" hdi.psztext="buffer;
" hdi.cchtextmax="256;
" verify(pheader-="">GetItem(i, &hdi));
hdi.fmt = (rgcAlign[i]==LEFT?HDF_LEFT:(rgcAlign[i]==CENTER?HDF_CENTER:HDF_RIGHT));
hdi.pszText = buffer;
hdi.cchTextMax = 256;
VERIFY(pHeader->SetItem(i, &hdi));
}
}
|
|
|
|
|
Check the replies in the microsoft.public.vc.mfc newsgroup.
|
|
|
|
|
Hi,
I am filling my tree control with elements, and each element has an image. but there are some elements that dont need an image. How can I do this? (I ve been stuck on this all afternoon )
I create and load the image list like this:
m_imageList.Create( IDB_SIMULATIONICONS /*name of the bitmap*/,
17 /*size of the bitmap*/,
1 /*ngrow*/,
RGB(255,255,255) /*mask*/ );
m_tree.SetImageList( &m_imageList, TVSIL_NORMAL );
I insert my elements to the tree like this:
HTREEITEM item;
item = m_tree.InsertItem( "Tree Item",
3 /*image index nr.*/,
4 /*selected image index nr.*/
);
I have tried NULL and -1 but it doesnt work. I would appreciate any help.
-thanks
A. Paluszny
|
|
|
|
|
You can't. The only way to do that is to custom draw your Treecontrol, which is not easy. You could display an empty image, but the items position would be shifted from the image width, and it looks ugly IMHO (items seem to hang in the air )
~RaGE();
|
|
|
|
|
Maybe somebody of you can guide me you to use the QoS SDK in order to use it as a Bandwidth Manager. I've searched for hours but without any success, maybe there is an tutorial or source code available.
thank you
Mario
|
|
|
|
|
I am running Visual C++ 6.0 Standard and when i compile my programs, the compiler never completes. I must then end the process to close c++ 6. If anyone can help, it would be appreciated.
|
|
|
|
|
Does it happen for hello world type program ? all programs or just one in particular ?
put some of your code in comments, and check where it freezes ?
if nothing works, uninstall VC and reinstall, apply patches and service packs; upgrade platform SDK, ...
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Hi i'm writing a multithreaded TCP server with my own protocoll. I had to switch to a simple multithreaded model because Win9x doesnt support IOCP. I've looked at a lot of examples already, but still i face the same problem. The samples i've looked at have a client thread function that handles each client seperately (like and echo server of files transfer server or whatever). But the problem is that i need to be able to send data to all of the clients at once, like a chat server would do.. When someone types a message, it gets processed and depending wether its a private message or a message intended for a certain room or just all clients it is broadcasted or sent to a specific ip. I thought about making a list of all the socket handles that have a connection running and then simple making a function that sends the data on all these sockets but i am affraid this will mess up the threads somehow.. and that it is just too simple. Does anyone know how this is generally implemented?
Kuniva
--------------------------------------------
|
|
|
|
|
This DWORD offset points to a list of null terminated strings containing alternate RAS phone numbers. I have gotten it to work using Visual C++ 6.0/Windows 2000 but it only seems to allow phone numbers.
Does anyone know if there is some magic format that will allow me to include strings for the alternate phone entry comments line? We have been manually copy and pasting numbers for ISP's for our state in the phonebook files and would like to automate it. The comment line is necessary to identify what city the phone number is good for.
I can parse the phonebook for the entry's key after using RASSetEntryProperties and trigger off of 'DEVICE=modem' to insert the alternate list including the comments section but this seems somewhat cheesy.
Any suggestions or alternate solutions welcome,
Thanks
|
|
|
|
|
hello,
I have a big problem, I want to print a page (with MFC) and everything worked fine until I tried to print a colored text .... if I try to draw on printer CDC a color line or rectangle it works but with text don't ! why ?... if my color is less then RGB(255,128,0) the text is black if my color is greater the text is white ... please help ...
thanks!
|
|
|
|
|
maybe a silly answer..
but maybe your printer driver has got gray-scale set as default?
check out the DEVMODE -structur (membervar in CPrintDlg).
It has a member dmColor. It can be set to DMCOLOR_COLOR or DMCOLOR_MONOCHROME. Set it correctly and it should work.
<code>
CPrintDialog dlg;
m_DC = new CDC;
m_DC->Attach(r_printdlg.GetPrinterDC());
m_DC->m_bPrinting = TRUE;
DEVMODE* pDevMode = r_printdlg.GetDevMode();
pDevMode->dmColor = DMCOLOR_COLOR;
m_DC->ResetDC (pDevMode);
Maybe this works..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Dear All,
I am developing an application in MFC VC++ Version 6.0 for Windows 2000. I have used some header files to support some functions , I have included a header file #include <afximpl.h> which is giving error
The error is:
fatal error C1083: Cannot open include file: 'afximpl.h': No such file or directory
Error executing cl.exe.
Can any body suggest why this error is coming and some way to solve this error.
I have this header file in my vc/src directory
Feel free to ask any further queries in this regards,
Thanks
Rohit Dhamija
|
|
|
|
|
Try this: #include "..\src\afximpl.h"
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
It could be a number of things. First click Alt+F7 (Project/Settings). Select the C++ tab, and the Preprocessor category. In the Additional include directories box, add the (absolute or relative) path to the ...\MFC\SRC folder.
Did that do it?
|
|
|
|