Need help incorperating SOCKS5 Proxies into C++ program

  • Context: C/C++ 
  • Thread starter Thread starter x2Dread2x
  • Start date Start date
  • Tags Tags
    C++ Program
Click For Summary

Discussion Overview

The discussion revolves around incorporating SOCKS5 proxies into a C++ chat bot program. Participants explore various technical aspects of network programming, event-driven design, and file handling for proxy lists.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in integrating SOCKS5 proxies into their chat bot and seeks assistance.
  • Another participant suggests making the network code event-driven and mentions the use of non-blocking socket functions for better performance.
  • There is a proposal to create a system-specific thread class and utilize the select method for cross-platform compatibility.
  • Discussion includes the importance of encapsulating functionality and managing system resources through specific manager classes.
  • A participant inquires about using a text file to load proxies and expresses uncertainty about how to implement this.
  • Another participant confirms that using a text file for proxies is feasible and advises on validating the structure of the data before use.
  • There is a suggestion to thoroughly analyze variable bounds and modularize code for better reliability.

Areas of Agreement / Disagreement

Participants generally agree on the importance of event-driven design and proper resource management, but there are varying levels of experience and understanding regarding implementation details, particularly in handling proxy lists.

Contextual Notes

Participants express uncertainty about specific implementation techniques, such as file handling and data validation, which may depend on individual project requirements and coding practices.

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.
 

Similar threads

  • · Replies 43 ·
2
Replies
43
Views
8K
  • · Replies 14 ·
Replies
14
Views
35K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 29 ·
Replies
29
Views
8K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K