C/C++ Need help incorperating SOCKS5 Proxies into C++ program

  • Thread starter Thread starter x2Dread2x
  • Start date Start date
  • Tags Tags
    C++ Program
AI Thread Summary
Incorporating proxies into a C++ chat bot program presents challenges, particularly with using a SOCKS 5 wrapper. To enhance network code, it is recommended to adopt an event-driven architecture, utilizing non-blocking socket functions and a cross-platform approach with a system-specific thread class. Proper initialization and shutdown of OS-specific components, like WSAStartup, are crucial. Building network classes for both client and server, along with a Network Manager to handle system variables, is essential for effective resource management. For loading proxies from a text file, it is feasible to use an input file stream, ensuring that each line is properly tokenized and validated for numeric values. Emphasis is placed on thorough analysis of variable bounds and structural definitions, advocating for modular code development and meticulous testing from the smallest data structures upward. This structured approach aims to mitigate potential issues in the program's design and functionality.
x2Dread2x
Messages
2
Reaction score
0
Hi there. I've been trying to incorporate Proxies into a program I am currently making.

It's basically a c++ Chat bot that will load proxies from a list and connect from them into a chat, but I'm having a bit of trouble.


I've found a SOCKS 5 Wrapper, but I'm having trouble with that as well.


Any help would be appreciated greatly.
 

Attachments

Last edited:
Technology news on Phys.org
x2Dread2x said:
Hi there. I've been trying to incorporate Proxies into a program I am currently making.

It's basically a c++ Chat bot that will load proxies from a list and connect from them into a chat, but I'm having a bit of trouble.


I've found a SOCKS 5 Wrapper, but I'm having trouble with that as well.


Any help would be appreciated greatly.

Just a bit of advice: I would setup your network code to be as event-driven as possible. Since you're assuming the socket has a minimum version of 2.0 you should be able to setup a non-blocking socket function quite easily.

If you want cross platform, one method might be to have a thread class that is system specific, but use the select method (which I'm sure is universal for standardized socket libraries on linux, unix, and mac).

Even if you only have 2 people chatting, it is worth making the effort to do the above.

Have some OS class that does all of your OS specific initialization which will include you starting and shutting down OS specific stuff (WSAStartup and include the function to release the library handle!)

Then build your network classes with client and server classes. Track all of your system variables and make sure your Network Manager class shuts everything down properly.

It might seem like I'm having a dig but I'm not: I think you have to get into the routine of seeing where to encapsulate functionality and especially where centralized flow control can and should be used: as a rule of thumb any system resource should be tracked by specific manager classes as well as OS classes. When you do something to an object, post an event message that any class can subscribe to. If something is destroyed one class can get messages and update things like pointer lists and so on.

Like I said, it might not be what you want to hear, but if you do this most of your problems will be solved when you think about the design and do so in a way that is optimal for what you want to do.
 
chiro said:
Just a bit of advice: I would setup your network code to be as event-driven as possible. Since you're assuming the socket has a minimum version of 2.0 you should be able to setup a non-blocking socket function quite easily.

If you want cross platform, one method might be to have a thread class that is system specific, but use the select method (which I'm sure is universal for standardized socket libraries on linux, unix, and mac).

Even if you only have 2 people chatting, it is worth making the effort to do the above.

Have some OS class that does all of your OS specific initialization which will include you starting and shutting down OS specific stuff (WSAStartup and include the function to release the library handle!)

Then build your network classes with client and server classes. Track all of your system variables and make sure your Network Manager class shuts everything down properly.

It might seem like I'm having a dig but I'm not: I think you have to get into the routine of seeing where to encapsulate functionality and especially where centralized flow control can and should be used: as a rule of thumb any system resource should be tracked by specific manager classes as well as OS classes. When you do something to an object, post an event message that any class can subscribe to. If something is destroyed one class can get messages and update things like pointer lists and so on.

Like I said, it might not be what you want to hear, but if you do this most of your problems will be solved when you think about the design and do so in a way that is optimal for what you want to do.


Yes, I get where you are going with this.. I've been working on a separate project, and it seems that all of it works much better and outputs with a better network code and event driven environment.

Would it be possible to use inFile to actually use a list text file with the proxies?.. I just can't wrap my head around it.

I suppose I can't say I've had too much experience with this.
 
There is no reason why you couldn't do that. I would probably make sure the structure is correct before you accept it though. Basically every line you get tokenize the data using . as the separator and check that the values are numbers only (ie ascii value lies in range) and then use something like atoi to check the values.

Some advice for you is to kind of "super-analyze" everything. Think of the bounds of your variables, the structural definition in your class or struct defs, and make modular code that is as thorough as you can get: decompose everything into its tiniest data structure, check it, and build up your checking and testing from the lowest structure up.

Even if you have to get a blank paper out and draw it like a tree diagram to help you visualize it.

But yeah sorry to answer your question, no reason why you can't do that, just make sure you handle all the anomalies.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top