« first day (253 days earlier)      last day (2583 days later) » 

2:31 AM
Hi everyone good morning.
I create 10000 sockets like this:
vector<shared_ptr<tcp::socket>> sockets;
for (int i = 0; i < 10000; i++)
{
//sockets.push_back(shared_ptr<tcp::socket>(new tcp::socket(s)));
sockets.emplace_back(new tcp::socket(io_service));
}
But i cannot send data to server: boost::asio::write(sockets[i], boost::asio::buffer((char*)&code, sizeof(code)));
error: Error 3 error C2039: 'write_some' : is not a member of 'std::shared_ptr<boost::asio::ip::tcp::socket>' d:\program files\work\lib\boost_1_55_0\boost\asio\impl\write.hpp 49 1 cPMulitpleT
@VermillionAzure Hi. azure can you help me in c++ question and answer?
@VermillionAzure Thank you.
 
@AlexCerry Yes?
 
@VermillionAzure understand question.
 
@AlexCerry Because std::shared_ptr tries to act like a pointer, it also adopts the calling syntax of member functions.
 
@VermillionAzure How i solve this problem.
 
@AlexCerry So instead of using . you need to use ->
 
2:37 AM
@VermillionAzure where?
 
@AlexCerry I dunno. But somewhere you are calling .write_some instead of ->write_some
And it's complaining that you're calling it on the pointer and not the actual object.
 
@VermillionAzure Error is in this line: boost::asio::write(sockets[i], boost::asio::buffer((char*)&code, sizeof(code)));
 
@AlexCerry This is too many sockets, you might get some system memory error, orneed to recompile the kernel.
 
@Mikhail It's a compilation error though
 
@Mikhail its compile successfully. if i comment this line: boost::asio::write(sockets[i], boost::asio::buffer((char*)&code, sizeof(code)));
 
2:41 AM
I prefer to solve the business problem first :-)
 
@VermillionAzure My task is to connect with 1 server with 10000 clients.
 
@AlexCerry I know 0 networking by the way, so I'm probably not the guy to ask for that.
But your compilation error is such that
 
@Mikhail you?
 
?
 
@Mikhail you know how can i solve this problem?
 
2:43 AM
Anyways, you can get a sense of how many sockets a single LAMP style instance can support if you look at "siege engine" testing
Also use a recent version of Boost like 1_63
 
@AlexCerry It's a type error. I can't really help you much more if you don't actually post the code and the error
And I don't know Boost.Asio anyways.
 
vector<boost::shared_ptr<tcp::socket>> sockets;
for (int i = 0; i < 10000; i++)
{
//sockets.push_back(shared_ptr<tcp::socket>(new tcp::socket(s)));
sockets.emplace_back(new tcp::socket(io_service));
}
std::shared_ptr<boost::asio::ip::tcp::socket> currentSocket;

for (int i = 0; i < sockets.size(); i++)
{
//tcp::socket ss(shared_ptr<tcp::socket>(sockets[i]));
//boost::shared_ptr<tcp::socket> socket =
//boost::make_shared<tcp::socket>(boost::ref(io_service));

//currentSocket = std::make_shared<boost::asio::ip::tcp::socket>(io_service);
boost::asio::write(sockets[i], boost::asio::buffer((char*)&code, sizeof(code)));
}
 
@AlexCerry Use a Pastebin instead of copy + paste.
@AlexCerry Also, one last thing is that I'm not so sure if you need to go &code
 
@VermillionAzure pastebin not working in china.
 
@AlexCerry Then find another site
 
2:45 AM
error is in this line: boost::asio::write(sockets[i], boost::asio::buffer((char*)&code, sizeof(code)));
 
@AlexCerry I don't know
 
@VermillionAzure its ok.
 
Sorry.
 
@VermillionAzure no problem.
 
2:56 AM
@Mikhail Any example 2 client connect with one server winsock or boost any ok?
 
I haven't used those in a long time. For low-throughput communication I prefer ZeroC Ice, for high throughput stuff I'd use MPI. For websites/games I've used tomcat, php, I think things like node.js might scale better.
 
@Mikhail Any example in ZeroC Ice to create multiple clients and connect with one server?
 
yes
But 10,000 is a very large number
 
@Mikhail 100 also ok. Can you send link?
 
3:04 AM
@Mikhail That is simple client.
Writing and Compiling a Client in C++
@Mikhail what about multiple client?
 
3:17 AM
So I'm interested in being a c developer. What skills should I pick up and look for in a job? Also I think working with hardware is cool
 
@TylerHilbert arduino.
 
Is that good for learning or are there lots of jobs using arguing?
 
Many jobs involve arguing to some extent.
 
user406009
@TylerHilbert Arduinos are primarily just an easy to use test board sort of thing.
 
user406009
I don't think a lot of people use them "in practice"
 
user406009
3:20 AM
Although I have never done anything even close to embedded work.
 
^ Arduino is a great introduction to embedded programming
 
@TylerHilbert When you know basic about arduino. You can jump to stm32.
 
user406009
I mean, a lot depends on what exactly you want to do with C. Fiddling with an arduino isn't very useful if you are interested in working on OS kernels.
 
I'm unfamiliar with stm32. What is it?
 
@Aaron3468 I agree. And also atmega with atmel studio.
@TylerHilbert stm32 is 32 bit processor.
@TylerHilbert Arduino uno use 8bit processor like atmega 8.
 
3:24 AM
@TylerHilbert An mcu. Basically a little computer that has just enough to turn electricity on and off in fancy ways.
 
Are there jobs open in so kernels? Everyone I talked to says stay away from system level programming because the job market is dead
@Aaron3468 so how's that different from a microprocessor or an arduini
 
@Aaron3468 Its can do more then that. Not just on and off.
 
@AlexCerry Yep, just simplifying.
 
@Aaron3468 ok
 
@TylerHilbert Don't worry too much about jobs in programming when you still need to learn. Maybe an internship, but I wouldn't hurry if you have no projects under your belt. Arduino is just a really easy mcu to get started with. The software is gentle as far as mcu software goes.
 
3:28 AM
I mean I have 2.5 years of on job web development experience I just hate fixing people's broken websites so I want to work in a new field
 
Ah, that's fair then. Most of the advertised jobs seem to be in web dev right now, but that's not my cup of tea either. Programming for desktops/hardware is a lot more headscratching and reading documentation, less design work.
 
@Aaron3468 programming jobs like gui creation or windows application is popular?
 
So what are the different fields within c or lower level programming? I know about system levels programming and embedded programming. Possibly control system. Writing drivers. Is disassembling executables for security reasons a thing?
 
@AlexCerry Stuff like making websites or connecting them to SQL databases.
 
@Aaron3468 yes also like mfc, qt or directui.
@TylerHilbert Low level programming. When you program your mcu its a low level programming.
 
3:40 AM
@TylerHilbert There's kernel development, which doesn't have a huge market. There's lots of security stuff (you'll usually need master's degrees or better). Also a bit of HPC.
 
Is there an actual job market in hpc? How would one learn that and get a job for it
 
There's definitely a job market, but like a lot of careers, the most difficult part is getting your foot in the door and proving you can keep up.
 
Ah. Is hpc the same thing as cloud computing?
Also is it really all in c and low level languages
 
Is anyone here good with metaprogramming and template design?
 
user406009
@DustinGoodson I believe most of those people are still asleep, but feel free to ask your question.
 
user406009
3:51 AM
It really depends on how complicated your problem is.
 
@TylerHilbert A lot of it moved to C++. Some of the financial industry still uses COBOL and Perl. I know a couple of people use languages for the GPU to run code. Not sure how much overlap high performance computing has with cloud computing, but I know it can include the clusters that run 'the cloud'
 
@AlexCerry what is a good beginning project for arduino or embedded programming
 
@TylerHilbert blink led.
@Aaron3468 what about my question?
 
Look stuff up on google. Lots of arduino stuff online. Best way to learn is to get started and make mistakes :)
 
@AlexCerry I've got blinking leds working and I have one arduino controlling blinking leds over Bluetooth for another arduino. What would be the next step?
 
3:55 AM
@AlexCerry Which one?
 
Well, I am getting an ambiguous template instantiation error when passing classes that are themselves templated classes... maybe i am not doing this right
 
@Aaron3468 programming jobs like gui creation or windows application is popular?
 
I reduced it down to this example
 
@TylerHilbert Try to connect ov7670 with arduino.
 
I don't know. There's still a market for windows applications, so it's mostly a matter of finding companies that do it
 
3:56 AM
@Aaron3468 Which field you are working?
 
user406009
@DustinGoodson What compiler are you using? I can't seem to reproduce any errors on my clang.
 
None at the moment. I'm attending university for a field called operational research, although I wouldn't mind drifting into ai/robotics.
 
user406009
clang version 3.8.1-16 (tags/RELEASE_381/final)
 
by the way next year i am going to graduate.
@Aaron3468 PHD student?
 
Finishing my undergrad. We'll see how getting internships works before I jump at more schooling ^^;
 
4:00 AM
@Aaron3468 you are bachelor student which year?
 
3rd
 
@Aaron3468 oh god. Same as me. I am also in 3rd year.
I am in 6th semester
@Aaron3468 Computer science?
 
Yeah
 
@Lalaland that is the weird thing. clang is the only compiler i know that allows this. GCC fails always. Could it be a compiler bug?
 
@Aaron3468 I am going to try for scholarship in master.
@Aaron3468 Canada university grade system MAX gpa is 4.0 correct?
 
user406009
4:03 AM
@DustinGoodson Probably. Hard to tell which compiler the bug is in. I don't know the standard well enough here to tell which is right.
 
user406009
One way to force a solution to your problem would be some SFINAE tricks with std::enable_if
 
Yeah, gpa goes to 4.0
 
@Aaron3468 I guess your more then 3.5.
 
g++.exe (Rev2, Built by MSYS2 project) 6.3.0 is my compiler... Do you have any suggestions on who I might ask or where I should ask to find out definitively if this is a compiler error?
 
user406009
@DustinGoodson Post on StackOverflow. Have that snippet of code in the question and you should get a quick answer.
 
4:08 AM
@Lalaland Thanks for the help
 
@Lalaland iResult = send(test[i], sendbuf, (int)strlen(sendbuf), 0);
@Lalaland I create 100 socket i can only send data to first one.
then i get this error 10057.
@Lalaland for (int i = 0; i < 2; i++)
{
test.push_back(socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol));
if (test[i] == INVALID_SOCKET) {
printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
}
 
user406009
@AlexCerry That looks like the sort of error you would get for not properly calling connect or accept or whatnot.
 
user406009
But I have to go to bed. Good night.
 
@Lalaland its client.
for (int i = 0; i < test.size(); i++){
// Connect to server.
iResult = connect(test[i], ptr->ai_addr, (int)ptr->ai_addrlen);
@Lalaland I solve it.
 
4:48 AM
@Telkitty :>
 
 
3 hours later…
8:13 AM
@sehe Hi. Good evening.
@sehe if you few minute. just few. I can ask something? I try a lot.
I try creating program which can connect 1 server with 100 client. so far i try this:
but its only send 8 time. then failed.
I try creating program which can connect 1 server with 100 client. so far i try this:
pastebin.com/eEzvLimZ
but its only send 8 time. then failed.
 
9 messages moved from Lounge<C++>
 
 
10 hours later…
5:58 PM
say I have a game
where there are quite a few enemies
 
you have a game
 
all are entities
with update loops
 
all enemies are entities and there's quite few of them
and they have update loops
 
or at least behavior that needs updating every frame
do I in my game's game loop's update method
just cycle through a list of all entities and call their respective update loops?
 
@exitcode that's one possible way to do that
 
 
2 hours later…
8:01 PM
hi guys
I have this class
template<typename K>
class Node {
public:
	Node();
	Node(const Node<K>& x);
	void setKey(const K& x);
	void setNext(Node<K> * const & x);
	void setPrev(Node<K> * const & x);
	Node<K>* getNext() const;
	Node<K>* getPrev() const;
	void insertNode(Node<K>* const & nil);
	void removeNode(Node<K>* const & nil);
	K getKey() const;
private:
	K key;
	Node<K>* next;
	Node<K>* prev;
};
and then this piece of list class
template<typename K>
class List {
public:
	List();
	List(const List<K>& x);
	void insert(const K& x);
	MyIterator<K> begin();
	MyIterator<K> end();
protected:
	Node<K>* getSentinel() const;
private:
	Node<K> sentinel;
};
And I was wondering
if the following class has the correct interface for an iterator stl style
template <typename K>
class MyIterator {
public:
	MyIterator(const List<K>& x);
	~MyIterator();
	MyIterator(const MyIterator& it);                   // Copy constructor
	MyIterator& operator=(const MyIterator& it);        // Assignment operator
	MyIterator& operator++();                   // Next element
	K& operator*();                    // Dereference
	bool operator==(const MyIterator& o) const; // Comparison
	bool operator!=(const MyIterator& o) const {
		return !(*this == o);
	}
	void setCurrent(Node<K> * const& x);
 
 
3 hours later…
10:34 PM
@user8469759 If it is STL style I would expect to be able to use it just like an STL type. E.g. can I write
List<Foo> list;
/* ... populate the list. */

List<Foo>::iterator liter, lend = list.end();
for(liter = list.begin(); liter != lend; ++liter)
{
	/* ... use *liter. */
}
 
nwp
@Brandin Why do people declare iterators like that? I have never needed that.
 
@nwp What do you mean? How else would you write it (in C++98)?
or C++03
 
nwp
at the very least put the iterators into the for-loop
didn't know C++98 was a limitation, then you can't actually do better I guess
 
If you have C++11 then use a range based for loop. Otherwise I guess you have to use something like the above. Of course there are variations in style, which is the main reason for the confusion. It's a lot to write for such a simple concept (looping).
 
nwp
I see default constructed iterators surprisingly often in other people's code and never in mine.
 
10:51 PM
Probably people just learned to write it a certain way and then just keep doing that. Stick with what works, you know.
 
11:20 PM
@user8469759 try writing unit tests for that - pass such an iterator to standard algorithms, and check whether they behave as you expect
 

« first day (253 days earlier)      last day (2583 days later) »