Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

justin223

@justin223
About
Posts
36
Topics
18
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problems with sockets (win32)
    J justin223

    John M. Drescher wrote: One thing to make sure with IOCP is that you should make sure the same socket is not serviced by more than one thread at a time otherwise you will have problems. Why? Im using CriticalSections..

    C / C++ / MFC sysadmin algorithms question

  • Problems with sockets (win32)
    J justin223

    Hello I've got a client/server application that sends small packets 10-50 bytes. The server, running win2000, uses IOCP and WSARecv + WSASend. The client uses an ownmade socket class also using WSARecv/WSASend and overlapped IO. Both the client/server waits for a Read, handles it and invoked WSARecv again. WSASend is only invoked when something is waiting in the outbuffer. Serverside: The first two transactions are handled ok (both transactions are sent at the same time and is recieved with the same WSARecv). But the second transaction, sent a couple of seconds later, will not be read by the server. The IOCP function gets called by the WSARecv but 0 bytes read are reported. ClientSide: After the last send I do a WSAGetOverlappedResult and it reports that the bytes were sent. I've tried to disable the nagle algorithm and setting SO_SNDBUF + SO_RCVBUF to 0 in the client. I've also tried to set SO_SNDBUF/SO_RCVBUF to zero in the server. client log: Socket(3)(Connect): WSAConnect() OK! Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 0 Send Trans: 2 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult Recieve, Trans: 0 Socket(2)(Read): 71/71 bytes handled Socket(3)(Read): WSARecv Socket(1)(Read): Completed directly 14 bytes Recieve, Trans: 2 Socket(2)(Read): 14/14 bytes handled Socket(3)(Read): WSARecv Socket(3)(Read): pending read... Send Trans: 3 Socket(3)(Send): New data triggered. Socket(1)(Send): WSASend Socket(3)(Send): Write completed Socket(3)(Read): Read completed. Socket(2)(Read): WSAGetOverlappedResult <- returns 0 bytes serverlog: prio: 1 client: 4 Connect from 127.0.0.1:1201 prio: 1 client: 4 Read -> Incomming bytes: 29 prio: 3 client: 4 Recieve, Trans: 0 prio: 3 client: 4 Send, Trans: 0 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 71/71 bytes. (flags: 0) prio: 3 client: 4 Recieve, Trans: 2 prio: 3 client: 4 Send, Trans: 2 prio: 1 client: 4 Send -> WSASend prio: 2 client: 4 Send ->Sent 14/14 bytes. (flags: 0) prio: 2 client: 4 Read -> 29/29 bytes handled prio: 1 client: 4 Read -> WSARecv prio: 2 client: 4 Read -> Pending read inited prio: 0 client: 4 0 bytes read! prio: 1 client: 4 Read -> aborting, dead or shutting down... What am I doing wrong?

    C / C++ / MFC sysadmin algorithms question

  • STL, &quot;upgrade&quot; from sprintf to ostream in a logclass
    J justin223

    Yep. I've started to do so.

    class CDtLog 
    {
    
    private: 
    	std::ostringstream	m_os;
    	bool		bNewEntry;
    	int		m_nPrio;
    	char*		m_szGroup[40];
    
    public:
    	CDtLog()
    	{
    		bNewEntry = true;
    		m_nPrio = 2;
    		m_szGroup[0] = NULL;
    	}
    
    	template
    		CDtLog &operator<<(const T &item)
    		{
    			if (bNewEntry)
    			{
    				m_os << "";
    				bNewEntry = false; 
    			}
    			m_os << item ;
    			return *this;
    		};
    
    		void print()
    		{
    			printf(m_os.str().c_str());
    		}
    };
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	CDtLog test;
    	int i = 10;
    	test << "hejsan" << std::setfill(' ') << std::setw(10) << 12 << i;
    	test.print();
    
    
    	return 0;
    }
    

    I need a modifier that tells me that a debugentry is done, similiar to endl, but instead of just flushing, it ends the xml tag and then flush it to the file. I also need to check every entered character to see if it's a < or >, if so I need to translate it to > or <, or it will ****up the xml. I also want modifiers that I can use to change the prio and group.

    ATL / WTL / STL question c++ xml

  • STL, &quot;upgrade&quot; from sprintf to ostream in a logclass
    J justin223

    Hello I've written a logfile class that writes the logentries in xml format. A typical usage: mylog.WriteLog(LOG_PRIO_HIGH, "Agroup", "This is a text with %d some %s vars", 34, "diffrent"); output This is a text with 39 some diffrent vars I want to accomplish the same thing by using streams/stringbuf. But I've not found any good examples that show me how I should do. What i've found is a couple of examples that derives a class from stringbuf and from ostream. I would be nice of I can get something like this: log << log_prio(1) << log_group("test") << "hello" << nIntVar << strBuf << log_end; log << "this is a string"; log << " something more" << log_end; log << log_prio(2) << "last line" << log_end; would look like: hello1yeye this is a string something more last line How do I accomplish this? Thanks, Jonas

    ATL / WTL / STL question c++ xml

  • Migrate from printf to streams in my logfile class.
    J justin223

    Hello I've written a logfile class that writes the logentries in xml format. A typical usage: mylog.WriteLog(LOG_PRIO_HIGH, "Agroup", "This is a text with %d some %s vars", 34, "diffrent"); output <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="Agroup">This is a text with 39 some diffrent vars</entry> I want to accomplish the same thing by using streams/stringbuf. But I've not found any good examples that show me how I should do. What i've found is a couple of examples that derives a class from stringbuf and from ostream. I would be nice of I can get something like this: log << log_prio(1) << log_group("test") << "hello" << nIntVar << strBuf << log_end; log << "this is a string"; log << " something more" << log_end; log << log_prio(2) << "last line" << log_end; would look like: <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="test">hello1yeye</entry> <entry date="2003-01-01" time="20:01:32:2200" prio="1" group="test">this is a string something more</entry> <entry date="2003-01-01" time="20:01:32:6600" prio="2" group="test">last line</entry> How do I accomplish this? Thanks, Jonas

    C / C++ / MFC question xml

  • Serial Comms Problem
    J justin223

    Try to read only 1 byte in ReadFile

    C / C++ / MFC help c++

  • Own client/server and 10053 problem
    J justin223

    oops. I do this before acceptex: m_sdClient = socket(AF_INET, SOCK_STREAM, 0); if (m_sdClient == INVALID_SOCKET) { m_nState = STATE_DEAD; WriteLog(LI_HIGH, "Couldnt reinit a socket\n"); return; } DWORD dwBytesRecvd;

    C / C++ / MFC help question sysadmin

  • Own client/server and 10053 problem
    J justin223

    Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.

    C / C++ / MFC help question sysadmin

  • Own client/server and 10053 problem
    J justin223

    Hello I got a client/server solution where I use IOPORTS in the server. Sometimes I get 10053 on WSASend/WSARecieve. Why do I get 10053 in the server, and how do I resolve it? Im not asking what the exact problem is, but to give me possible reasons that will help me to pinpoint the problem. "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error. " Doesnt help me that much.

    C / C++ / MFC help question sysadmin

  • CEdit Control
    J justin223

    CDC* pDC = GetDC(); char szTmp[256]; edt.GetWindowText(szTmp); int nSize = pDC->GetTextExtent(szTmp).cx; //and now simply compare the edt width with nSize;

    C / C++ / MFC help

  • Serial communication problem
    J justin223

    Hello I got problems with serial communications, I use workerthread and overlapped io. Everything works really nice on one computer, but on another one it dont. ReadFiles overlapped read event doesnt get triggered, Writefile works as it should. What can be wrong?

    C / C++ / MFC help question

  • Problem with serial communication
    J justin223

    Hello Im using serial communicating (COM3 and COM4) to talk with another server. I use the exact same settings and the same class (overlapped io with readfile/writefile) to communicate with the server (diffrent protocols). Everything runs smoothly on COM3, but the overlapped read doesn’t complete for COM4 (as nothing is received). If I connect to COM4 using hyper terminal everything works (both send and receive). What can be wrong? Thanks, Jonas

    C / C++ / MFC sysadmin help question

  • Is WaitCommEvent() buggy?
    J justin223

    Hello A colleague of mine told me not to use WaitCommEvent() since it's not 100% reliable. Can anyone back this up? Thanks, Jonas

    C / C++ / MFC question

  • Aborting a socket accept() after X seconds
    J justin223

    Hello Is it possible to abort a socket accept after X seconds? I got two classes: cfiletransferserver and cfiletransferclient. I launch a cfiletransferserver on a specific port and than send the port to my client application. The client application then tries to connect to the server by using cfiletransferclient. cfiletransferserver deletes itself from the stack when the filetransfer is finished. I want cfiletransferserver to delete itself if no cfiletransferclient have connected to it in X seconds. How do I do that? Thanks, Jonas

    C / C++ / MFC question sysadmin data-structures

  • Strange result
    J justin223

    Martyn Pearson wrote: This comes down to the order in which the operands are evaluated. Your first line expands to 815 - 0 - 1 + 2 + 4 + 1 i.e. 814 + 2 + 4 + 1 = 821 Do #define HVD_HEADER_SIZE (1 + 2 + 4 + 1) to get the results you are expecting! ofcourse :omg: Why didnt I think of that? :-D Many thanks!

    C / C++ / MFC question

  • Strange result
    J justin223

    Hello dwCopyLen = dwBufSize - dwSkipCount - HVD_HEADER_SIZE; how can dwCopyLen become 821 when: dwBufSize = 815 dwSkipCount = 0 #define HVD_HEADER_SIZE 1+2+4+1 //stx+USHORT+DWORD+char strange huh? If i split it to three lines: dwCopyLen = dwBufSize; dwCopyLen -= HVD_HEADER_SIZE; dwCopyLen -= dwSkipCount; I get the correct result. Why?

    C / C++ / MFC question

  • Making selected item bk 50% transparent in a ownerdrawn clistctrl
    J justin223

    I got a ownerdrawn clistctrl that I have a bk image in. How do I make the selected item background color about 50% transparent (I want to blend it with the bkimage)?

    C / C++ / MFC question

  • CImagelist and CListCtrl problem.
    J justin223

    thanks. But that doesnt help me. I want to know why it doesnt work. Why do the colors look fuckedup if I use the same overloaded version of create as you do? (The one where u specify the mask color) Why do the mask become black when I first load the bmp into a CBitmap and then load the CBitmap into the imagelist?

    C / C++ / MFC dotnet graphics help question

  • CImagelist and CListCtrl problem.
    J justin223

    I'm trying to load a bitmap into a imagelist, and to get a transparent background. The imagelist is used in a CListCtrl. When I load the bitmap directly I get transparent images, but wrong colors. m_ilReport.Create(IDB_TOOLBAR_GRID256, 16, 1, RGB(255,0,255)); If I load it into a CBitmap first the colors look ok, the problem is that the mask color is replaced with black. SetBkColor seems to have no affect. I've tried with regular colors too. m_ilReport.Create(16, 16, ILC_COLOR8, 16, 1); CBitmap bmp; bmp.LoadBitmap(IDB_TOOLBAR_GRID256); m_ilReport.Add(&bmp, RGB(255, 0, 255)); m_ilReport.SetBkColor(CLR_NONE); ctl.SetImageList(&m_ilReport); What have I done wrong?

    C / C++ / MFC dotnet graphics help question

  • WaitForMultipleObjects And notifying
    J justin223

    kuphryn wrote: It still would not become signaled even when you sign one or other events? Make sure the other handles are valid. well.. That was the first thing I checked. It's valid alright.

    C / C++ / MFC help security
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups