• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

iapetus

Scary Euro Man
Yeah... I have only dabbled in Xcode a bit since we mostly stick to web applications but I was totally lost when I did. It's probably part of the reason why people pony up and pay Xamarin.

Appcode looks passable as well - made by the same people as Android Studio, and while it's not as awesome (Java is their strong point) it's way better than Xcode...
 

injurai

Banned
The Mono/C# platform is really great and powerful. Sort funny that an implementation of Microsoft's .Net platform is winning people's hearts over Apple's domestic stuff.
 

OlympicTechno

Neo Member
The first one is a string. You need to split it to create an array

$('.redSTArray').text().split(",")

or something like that.

Thank you!

After searching for this I came across $.parseJSON which seemed a much easier method. Now instead if imploding, I echo a json_encode then parse it throught jQuery.

Thanks everyone.
 
So thus far you've not managed to connect to the DB with Java in any way?

With compiling and running in the console/terminal/cmd/whatever, have you got everything you need in your classpath?
(I know you've got the driver in the directory already, but still.)

The professor emailed us saying that the connection may only work on the campus's network. I suppose I'll build the database with WampServer and try it here at home. I'll give it a try tomorrow, already spent most of the day building the UI in preparation for when I get it working.
 
I'd just like to publicly apologise to any iOS developers out there. I thought you had it easy, with Apple's awesome tools and clear UI guidelines. I thought the amazing well-built APIs you were working with probably did half the job for you.

Now, however, I've actually used Xcode. I've looked at the documentation for changing an app's name. I've walked through some code for laying out what should be a simple piece of UI. And yeah, now I've realised that Apple are carrying out a perverse social engineering experiment in which they try to discover just how far Stockholm syndrome can be pushed.

So yeah, sorry.
Yes, Xcode is a disaster.
 

Aomber

Member
Well this is the first time I've seen this thread! Subbing for sure.

I actually might need some help with Java for some assignments I'm doing, I'm pretty behind and the semester is wrapping up soon. Will keep this thread in mind.
 
It's interesting. We write enterprise software here and I've definitely seen this problem here, but over the years I've been working here I've also seen huge improvements made in quality and professionalism. One of the great things about staying at one company for a longer time (6 years now).
Well, it certainly varies. Not all enterprise software falls into the pit.

(in general, the better your company pays its developers, the less unwanted turnover you have, the more likely you are to maintain a quality team and a quality code base)
 

Two Words

Member
How do you handle input validation in an object oriented program? It's simple input validation. The user can enter input of any size, but you just have to make sure it is a valid number or character. Do you make functions outside of all classes? Do you make the functions inside of classes? Do you make an input class?

This is done in C++.
 

Ambitious

Member
I have to work on a web application for a university lecture. However, my experience in web programming is extremely limited, so I would appreciate a few hints, mainly regarding the architecture and the project setup.

The application is split into several components. I'm responsible for the API component and the frontend, and my teammates will develop the backend services. There's a mandatory technology stack for the API component, so this post is concerned just with the frontend.

It's actually pretty simple: There's a public page displaying a simple interactive table (-> sorting, filtering). Users can log in, and they can have one of several roles. Depending on the role, the table will then show a different set of data. (The columns may vary slightly, too.)
Two of the roles can add and delete items, so they need a form to enter the data.

That's it. That's all the site is supposed to do. I could easily write this by hand and add the table interactivity with jQuery, but I'd rather try a professional approach in order to learn something useful.

I created a Bootstrap scaffold with Yeoman using the webapp generator, but now I'm not sure how to dynamically serve content. As I mentioned above, the table content depends on the role of the user.

Last semester, I worked on a small Node.js application, so I have a bit experience with that. Would Node be a good choice for something like that? If so, what's the best way to integrate it into my project? I followed the Getting Started guide of Yeoman, so my project uses Bower and Grunt. I haven't used either before. (This was the first time I used Yeoman as well.)

Related question: The way it looks, my site will consist of a single page. But if I were to add more pages, what would be the best way to avoid redundant HTML? For instance, the Node project mentioned above used the Jade Template Engine to embed all pages inside a basic layout template, which consisted of the head element, the menu bar and the main content container. We had a separate Jade file for each page, which was embedded into said container.

That wouldn't be too hard. Can you post the files?

Well, it's not hard, it's just tedious. I have already made a few modifications. But I decided to switch back to the default light theme. I kinda prefer it, though I guess that's just because I'm used to it.
 

tokkun

Member
How do you handle input validation in an object oriented program? It's simple input validation. The user can enter input of any size, but you just have to make sure it is a valid number or character. Do you make functions outside of all classes? Do you make the functions inside of classes? Do you make an input class?

This is done in C++.

There's no single answer to this. It depends on how your program is structured and when you are reading the input.

If you're reading it all up-front, you may just want to use a function that you call from main. If you are reading the input on demand in response to some conditions in your program, you may want to have a class that handles it.

If you're really not sure, try doing the simplest thing first, and if that turns out to be insufficient, you can implement something more complex later.

One solid piece of advice I can give: C++ has a built in class, std::istream, that can make the job easier for you.
 

Two Words

Member
There's no single answer to this. It depends on how your program is structured and when you are reading the input.

If you're reading it all up-front, you may just want to use a function that you call from main. If you are reading the input on demand in response to some conditions in your program, you may want to have a class that handles it.

If you're really not sure, try doing the simplest thing first, and if that turns out to be insufficient, you can implement something more complex later.

One solid piece of advice I can give: C++ has a built in class, std::istream, that can make the job easier for you.

At first I made the input validation functions inside the same file as main, but I don't get how I can call that function inside of a class function.
 

Slavik81

Member
Hey programming gaf..

Some questions what testing and mocking frameworks are used with
C++ and visual studio?
Google Mock is the only one I'm familiar with. My experience was... mixed. Other team members loved it, but I felt it was too much work for the results you got.
 
At first I made the input validation functions inside the same file as main, but I don't get how I can call that function inside of a class function.
Encapsulate it in a namespace or a class (in a separate file), test the namespace/class. Have main() include the separate file.
 
Google Mock is the only one I'm familiar with. My experience was... mixed. Other team members loved it, but I felt it was too much work for the results you got.

Okay, some friends did recommend me to use google mock and test as testing
frameworks. Yeah unit testing and writing mocks can be a pain in the ass. I do have
some experience writing test and mocks with .Net which is what i use at work.
So i wondered how it was done in the C++ world.

Also dived this evening into windows 10 universal app platform.
Doing some research by reading sample code.
So i can follow build 2015 better if they will have some
universal app platform for Xbox one talks. Seems a lot less confusing then the
win32 API.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
-- webapp stuff --

** Full disclosure: I am in no way an expert, but I will try to help with your questions. Check out the WebDev thread as well to get more advice. **

You mention Node, but then also mention that you will only be responsible for the frontend and API communication. So I don't think you will have to think about Node at all. The guys working on the backend could integrate that if they'd like, and you could use Jade with that, but it's dependent then on what they want to use. (Node is typically backend/server stuff)

You already have a Bootstrap/Yeoman core which is a good starting point. If I were approaching this, especially since you talk about it being single page primarily with dynamic elements, I would look into some simple work with Angular. It's built for that exact purpose after all, and runs entirely on the front-end. The syntax and structure can be daunting at first, but it's very powerful.

Also if you are familiar at all with Node, then I'm guessing you know about NPM. I think of Bower as the NPM of the Frontend. If that helps at all.

If you go the Jade route then you could serve out a page with all the relevant info based on a template file, (This could also work with Mustache/Handlebars), but I don't think you could have a dynamically updated page without reloads like you would get through Angular.

All else fails I'm sure you could get by with AJAX calls and then changing the HTML directly using jQuery, but where's the fun in that?
 

squidyj

Member
I'd been meaning to ask this for a while. I did code jam qualification round and got 3/4 questions answered (was busy during 1a so I'll hit up 1b), and I had a correct but naive solution for the 'Dijkstra' problem that resulted in taking too long to solve, and for some reason, probably a brainfart, I'm not seeing the more efficient algorithm for that problem.

for those who might not be familiar here's a link.
https://code.google.com/codejam/contest/6224486/dashboard#s=p2

What have I overlooked here?


Edit: I was going over it and I figured it out. you just need to verify first that the string multiplies to the result of ijk, then if you can find i from the front and k from the back, you'll have it. I can't believe I didn't think about that at the time.
 
Made some good progress on my java assignment once I could connect to the server.

Looking for some small help on prolog though. Making a 4x4 tic tac toe game (yes another one, after small talk lmao), I'm struggling understanding how to make my program unify a variable with another variable. Basically what I'm doing is finding the winning move of the player and having the AI block it. Then if there are no winning moves, it will look lines that will form 3 in a row and blocks the empty space.

move(A) :- good(A), empty(A), !.

good(A) :- ordered_line(A, B, C, D), o(A), o(B), o(C), empty(D), write('winning move detected.'), write(D), nl, assert(x(D)).
good(A) :- ordered_line(A, B, C, D), o(A), o(B), empty(C), o(D), write('winning move detected.'), write(C), nl, assert(x(C)).
good(A) :- ordered_line(A, B, C, D), o(A), empty(B), o(C), o(D), write('winning move detected.'), write(B), nl, assert(x(B)).
good(A) :- ordered_line(A, B, C, D), empty(A), o(B), o(C), o(D), write('winning move detected.'), write(A), nl, assert(x(A)).
good(A) :- ordered_line(A, B, C, D), o(A), o(B), empty(C), empty(D), write('attempting to block.'), write(C), nl, assert(x(C)).
good(A) :- ordered_line(A, B, C, D), o(A), empty(B), o(C), empty(D), write('attempting to block.'), write(B), nl, assert(x(B)).
good(A) :- ordered_line(A, B, C, D), empty(A), o(B), o(C), empty(D), write('attempting to block.'), write(A), nl, assert(x(A)).


% good(5). good(1). good(3). good(7). good(9). good(2). good(4). good(6).
% good(8). good(10). good(11). good(12). good(13). good(14). good(15).
% good(16).

By default (the professor's base program) good(A) unifies with the the numbered parameters goods() and it checks to see if the spot is empty on the board, and then works it way back up through other rules that called it and asserts the A position on the board.

What I want to do is instead of asserting my rules in good (the rules that aren't commented are what I have written) is to return the A value as the "empty spot" so that the function can continue as normal. Right now if I uncomment the bottom code it will make two turns. If I don't it won't complete the turn because good is expecting a value to be unified with. I tried for example


good(A) :- ordered_line(A, B, C, D), o(A), o(B), o(C), empty(D), write('winning move detected.'), write(D), nl, good(D).

but it ignores it and unifies with one of the "numbered" goods. I was under the assumption that good would unify with the value (D) and then return to the calling rule. This doesn't seem true though, when I try to do good(A) it results in an infinite loop because it keeps calling itself over and over :p. So does it need to be bound with a constant before it returns the calling rule? I'm unsure how to make D into a constant. The value is absolutely right though, when I write D it gives me a numeric value, and when I assert it, it writes to the intended position.


Still extremely new to prolog, we just started covering it last week. So I may be ignorant of some very basic concepts. I find it very hard to wrap my head around compared to clojure and small talk.
 
I'd been meaning to ask this for a while. I did code jam qualification round and got 3/4 questions answered (was busy during 1a so I'll hit up 1b), and I had a correct but naive solution for the 'Dijkstra' problem that resulted in taking too long to solve, and for some reason, probably a brainfart, I'm not seeing the more efficient algorithm for that problem.

for those who might not be familiar here's a link.
https://code.google.com/codejam/contest/6224486/dashboard#s=p2

What have I overlooked here?

What was your solution? Off the top of my head, you could start at the beginning and iterate through the input, keeping a running product. As soon as your product is i, you mark this position as the first separator. Now starting at this location, begin a new running product and as soon as your running product equals j, mark this point as the second separator. If the rest multiplies to k, you're done. If not, continue the previous running sum until you get to another j.

That's the naive solution. There are some improvements you can make though. While it may not be commutative, it *is* associative. In particular, this means that if it is reducible to ijk, then the product of the original string should be equal to the product of ijk, which is -1. So start by just multiplying everything, and if the result is not -1, immediately return false.

Is the converse true though? If the product is -1, is it necessarily reducible to ijk? Unfortunately not, using the table it's easy to find counter examples. kkkkkk is one example. See if that gives you any other ideas though. (If not I'll spoil it a little more)
 

squidyj

Member
What was your solution? Off the top of my head, you could start at the beginning and iterate through the input, keeping a running product. As soon as your product is i, you mark this position as the first separator. Now starting at this location, begin a new running product and as soon as your running product equals j, mark this point as the second separator. If the rest multiplies to k, you're done. If not, continue the previous running sum until you get to another j.

That's the naive solution. There are some improvements you can make though. While it may not be commutative, it *is* associative. In particular, this means that if it is reducible to ijk, then the product of the original string should be equal to the product of ijk, which is -1. So start by just multiplying everything, and if the result is not -1, immediately return false.

Is the converse true though? If the product is -1, is it necessarily reducible to ijk? Unfortunately not, using the table it's easy to find counter examples. kkkkkk is one example. See if that gives you any other ideas though. (If not I'll spoil it a little more)

I guess you didn't see my edit, yeah, what you said was my original naive solution, find each I as I walk through the string, then try to make J and see if the rest multiplies to K. but as I looked at it again today I realized that if I knew the total result was -1 and if I could find an I from the beginning and a K from the end, then if there were any remaining characters they must multiply to J. The key point being that I only need to look for the very first I and K that I can make, reducing the algorithmic complexity to O(n)

I also realized that the repetitions only matter to modulo 4 since for any value n, n ^ 4 = 1.

I'm kind of surprised so many people dropped the ball at pancakes and I don't know what the solutions people had for ominoes that failed the large test. All I had was a handful of rules based on the integers given.
 
I guess you didn't see my edit, yeah, what you said was my original naive solution, find each I as I walk through the string, then try to make J and see if the rest multiplies to K. but as I looked at it again today I realized that if I knew the total result was -1 and if I could find an I from the beginning and a K from the end, then if there were any remaining characters they must multiply to J. The key point being that I only need to look for the very first I and K that I can make, reducing the algorithmic complexity to O(n)

I also realized that the repetitions only matter to modulo 4 since for any value n, n ^ 4 = 1.

I'm kind of surprised so many people dropped the ball at pancakes and I don't know what the solutions people had for ominoes that failed the large test. All I had was a handful of rules based on the integers given.

An I from the beginning and a K from the end will work, but you'll have to be careful when you're looking for the K, because multiplication is not commutative. Why not just an I from the beginning and a J starting from where the I finishes?
 

Ambitious

Member
** Full disclosure: I am in no way an expert, but I will try to help with your questions. Check out the WebDev thread as well to get more advice. **

You mention Node, but then also mention that you will only be responsible for the frontend and API communication. So I don't think you will have to think about Node at all. The guys working on the backend could integrate that if they'd like, and you could use Jade with that, but it's dependent then on what they want to use. (Node is typically backend/server stuff)

You already have a Bootstrap/Yeoman core which is a good starting point. If I were approaching this, especially since you talk about it being single page primarily with dynamic elements, I would look into some simple work with Angular. It's built for that exact purpose after all, and runs entirely on the front-end. The syntax and structure can be daunting at first, but it's very powerful.

Also if you are familiar at all with Node, then I'm guessing you know about NPM. I think of Bower as the NPM of the Frontend. If that helps at all.

If you go the Jade route then you could serve out a page with all the relevant info based on a template file, (This could also work with Mustache/Handlebars), but I don't think you could have a dynamically updated page without reloads like you would get through Angular.

All else fails I'm sure you could get by with AJAX calls and then changing the HTML directly using jQuery, but where's the fun in that?

Oh, crap. I completely forgot about the WebDev thread. Sorry about that.
Thank you for your help.

AngularJS looks interesting. But it's completely client-side, isn't it?
As I mentioned, only some roles should see the form to enter data. How would I do that with Angular? Simply hide the div? Then a crafty user could unhide it by using the Web Inspector or Firebug. Of course, this shouldn't be a problem, as all requests pass the API component, which of course checks the user's permissions. But still, the better option would by to not include the form at all when sending the HTML to the client, no?
Sorry if that's a dumb question. I'm really quite inexperienced in the field of web development.
 

tokkun

Member
An I from the beginning and a K from the end will work, but you'll have to be careful when you're looking for the K, because multiplication is not commutative. Why not just an I from the beginning and a J starting from where the I finishes?

I don't see why that would be a problem. The fact that it is not commutative only prevents you from reordering the terms. The associative property lets you do the reductions in any order.

I also don't see a reason for the "continue until you find another j" step mentioned in your previous post; it seems redundant. Once you find the first j, if the remainder of the string doesn't reduce to k, you are done. Finding bigger j's is accomplished by appending strings that reduce to 1 to your previous j, and removing a prefix that reduces to 1 is not going to change the value of the remainder.
 
I don't see why that would be a problem. The fact that it is not commutative only prevents you from reordering the terms. The associative property lets you do the reductions in any order.

I also don't see a reason for the "continue until you find another j" step mentioned in your previous post; it seems redundant. Once you find the first j, if the remainder of the string doesn't reduce to k, you are done. Finding bigger j's is accomplished by appending strings that reduce to 1 to your previous j, and removing a prefix that reduces to 1 is not going to change the value of the remainder.

I only said that you'll have to be careful, not that it won't work. For example, you can't do prod *= next you would have to do prod = next * prod. Again, it will work, I just think that it leads to more difficult to understand code because the natural way of writing the code will be wrong.

As for your other point, it is redundant, but I didn't want to spoil the whole problem. I did say that was the naive solution after all. The key observation is the invariance of the complete product. Once you get that, all you need to do is find the first i, the next j starting from where the i ends, and then return true or false based on whether the remainder is k or not. You don't even have to check for -1, that's just more of a stepping stone to understanding the problem.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Oh, crap. I completely forgot about the WebDev thread. Sorry about that.
Thank you for your help.

AngularJS looks interesting. But it's completely client-side, isn't it?
As I mentioned, only some roles should see the form to enter data. How would I do that with Angular? Simply hide the div? Then a crafty user could unhide it by using the Web Inspector or Firebug. Of course, this shouldn't be a problem, as all requests pass the API component, which of course checks the user's permissions. But still, the better option would by to not include the form at all when sending the HTML to the client, no?
Sorry if that's a dumb question. I'm really quite inexperienced in the field of web development.

That could be handled. Maybe an example would help.
In a recent side project I worked on I had a database with an API that could fetch the data and return it to the client. The server was written in Node, but that's not important. On the client side I used Angular for displaying the information.

On page load, (or whenever you need data/new data), I made an API call to my database. Then the returned object was passed into Angular which had an ng-repeat div that filled up with whatever information it was given and formatted it based on a template.

This means that the API was what determined what did or didn't get shown on the page, and there was no code loaded into HTML that wasn't supposed to be there. So no pesky users would be able to open up the inspector and access info they shouldn't.
 
Hi! I'm learning Java, the little project on working on required me to have an int number(1) that I write to an uneditable JTextField, upon pressing a confirm button I want the int to increase by one so the next time I press the button it will display the next number incremented by one.

To try and do this I have:
{
number.setText(NumberString);
number++;
}
It is writing the first number(1) to the JTextField as expected, but the number doesn't increment so no matter how many times I press the button it is always setting the text as "1"

Any help would be massively appreciated!
 

kitzkozan

Member
I'm also learning java and I've got this project here which is finished at 99%. I'm currently stuck on an operation which consist of creating a method which allow me to filter information by combining specific month of birth and X consumed (can be pizza or anything) in order to count Y amount of person which fill these conditions (by scanning an array). I have the specific month down, but can't seems to find the correct sequence to add in X consumed, so I have:

int n = 0;
for(int i = 0; i < nbPerson; i++)
if (pers.month() == specificMonth) & (missing valid condition)?
n++;
return n;
 
Ok, sorry for the code dump, but I'm at my wits end. This is basic client/server code, but the client never connects to the server. What am I missing?

Server:
Code:
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <cstring>
#include <netinet/in.h>
#include <unistd.h>
//----
#define BUF_SIZE 1024
//----
using namespace std;


int
main(void) {
    int status = 0;
    int server_sock = 0;
    int client_sock = 0;
    struct addrinfo hints;
    struct addrinfo *servinfo;
    struct sockaddr_storage client_addr;
    socklen_t addr_size = sizeof(client_addr);
    char buffer[BUF_SIZE] = {'\0'};


    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;

    status = getaddrinfo(NULL, "8888", &hints, &servinfo);

    server_sock = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
    bind(server_sock, servinfo->ai_addr, servinfo->ai_addrlen);
    listen(server_sock, 5);

    client_sock = accept(server_sock, (struct sockaddr *)&client_addr, &addr_size);

    while(strstr(buffer, "quit")) {
        memset(buffer, 0, BUF_SIZE);
        recv(client_sock, buffer, BUF_SIZE, 0);
        send(client_sock, "Right back at ya!", 16, 0);
        send(client_sock, buffer, BUF_SIZE, 0);
        cout << "Got something" << endl;
    }

    close(client_sock);
    close(server_sock);
    freeaddrinfo(servinfo);

    return 0;
}
Client:
Code:
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <cstring>
#include <netinet/in.h>
#include <unistd.h>
//----
#define BUF_SIZE 1024
//----
using namespace std;


int
main(void) {
    int status = 0;
    int server_sock = 0;
    int client_sock = 0;
    struct addrinfo hints;
    struct addrinfo *servinfo;
    char buffer[BUF_SIZE] = {'\0'};


    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;

    status = getaddrinfo(NULL, "8888", &hints, &servinfo);

    server_sock = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
    client_sock = connect(server_sock, servinfo->ai_addr, servinfo->ai_addrlen);

    while(strstr(buffer, "quit")) {
        memset(buffer, 0, BUF_SIZE);
        send(client_sock, buffer, BUF_SIZE, 0);
        recv(client_sock, buffer, BUF_SIZE, 0);
        cout << buffer << endl;
    }

    close(client_sock);
    close(server_sock);
    freeaddrinfo(servinfo);

    return 0;
}
 

Slavik81

Member
Ok, sorry for the code dump, but I'm at my wits end. This is basic client/server code, but the client never connects to the server. What am I missing?
Why is your client searching for "quit" in is buffer?

EDIT: Also, why is the server searching? Buffer isn't passed to any function or set with any value besides '\0' until after you search for "quit". strstr is going to return NULL and the while loop is not going to execute.
 
Number isn't referring directly to the contents of the field, rather the JTextField object itself. You're going to have to increment the int separately before you pass its string to setText().
How would
I go about this? I've tried so many different things but nothing is working, it always just passes the value of 1 no matter where I try and increment it
 
Why is your client searching for "quit" in is buffer?

EDIT: Also, why is the server searching? Buffer isn't passed to any function or set with any value besides '' until after you search for "quit". strstr is going to return NULL and the while loop is not going to execute.
Ah, yeah that's a huge oversight. I never get there though because the client always fails to connect to the server and that's what I don't get.
 

tokkun

Member
Ok, sorry for the code dump, but I'm at my wits end. This is basic client/server code, but the client never connects to the server. What am I missing?

What is the first line that returns an error status code in both the client and the server, and what error numbers are they?
 

arit

Member
Code:
    client_sock = connect(server_sock, servinfo->ai_addr, servinfo->ai_addrlen);

    while(strstr(buffer, "quit")) {
        memset(buffer, 0, BUF_SIZE);
        send(client_sock, buffer, BUF_SIZE, 0);
        recv(client_sock, buffer, BUF_SIZE, 0);
        cout << buffer << endl;
    }

}

IIRC connect() only returns success/fail of the connection attempt, but not a handle to a socket itself. So you'd still have to create it with before connecting to the server. Using server_sock in this case, withing recv/send, might work without additional changes.
 
What is the first line that returns an error status code in both the client and the server, and what error numbers are they?
The server never returns an error as it sits at the accept() call. The client returns -1 at the connect(). I put in <cerrno> and it says the error is 111 "Connection refused."

IIRC connect() only returns success/fail of the connection attempt, but not a handle to a socket itself. So you'd still have to create it with before connecting to the server. Using server_sock in this case, withing recv/send, might work without additional changes.

Do you mind explaining this to me? Following Beej's network guide I was under the impression I only need to have a socket from the kernel and then I can connect to the server.
 
Also fixed my problem. In getaddrinfo() I was using NULL on the client side instead of specifying the IP address I wanted. Thanks tokkun and arit!
 

injurai

Banned
I like how y'alls code looks all organized. Mine is indistinguishable from ancient Hebrew written by a drunk dyslexic.

are you this guy?

1ubHwQr.gif
 
I like how y'alls code looks all organized. Mine is indistinguishable from ancient Hebrew written by a drunk dyslexic.

Haha nice analogy. If I'm living in a code base I want to be able to instantly understand whatever I look at; especially since comments aren't always left behind. Really transformed my style.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
More like this guy.

But I want my code to look neat. But I gave up when I realized that when I move the HTML from my end to the server, it just goes to shit. So, if I see something that I then need to copy that code from and retest on my personal server, it gets even more jumbled.

I went back to CoffeeCup, by the way for my HTML/CSS needs, by the way. I love the look of brackets, but not having tabs or the ability to test on different browsers instantly is a no go. I had 24! tabs of code open today and I have to test all of them on browsers as far back as IE8. Brackets, unless my Google Fu is failing me, only does the live view and only in Chrome. Which is sort of cute, but considering you have to save for the changes to go through...meh.

Brackets is sexy looking though.
 
More like this guy.


But I want my code to look neat. But I gave up when I realized that when I move the HTML from my end to the server, it just goes to shit. So, if I see something that I then need to copy that code from and retest on my personal server, it gets even more jumbled.

I went back to CoffeeCup, by the way for my HTML/CSS needs, by the way. I love the look of brackets, but not having tabs or the ability to test on different browsers instantly is a no go. I had 24! tabs of code open today and I have to test all of them on browsers as far back as IE8. Brackets, unless my Google Fu is failing me, only does the live view and only in Chrome. Which is sort of cute, but considering you have to save for the changes to go through...meh.

Brackets is sexy looking though.

Since version 1.1. of Brackets you can do live preview in multiple browsers. Just launch live preview and copy & paste the url to other browsers. https://github.com/adobe/brackets/wiki/Live-Preview-Multibrowser. You can enable it from the File-menu.

You can also, if you want to, easily get around that limitation by running something like grunt watch with livereload or gulp-livereload. If you haven't used Grunt or Gulp before, the setting up part takes only couple of minutes, but "getting it" might take more. Anyhoo, I'd say learning either one is pretty much as must of any Web Developer these days.

If you are doing freelance stuff, Browserstack is 12,99 a month @ https://www.browserstack.com/ and I'd say that if you really need to test all the browsers all the time up to IE8, it's worth the price alone. (It's free if you do open source stuff).
 

WanderingWind

Mecklemore Is My Favorite Wrapper
See, the important part of that is "compiled without errors."

Heh.

(I did use tables for an element this week. Plz forgive me)
 

poweld

Member
I don't mind interviewing candidates in person, but I find phone interviews to be difficult. Asking programming questions is obviously tough without being able to whiteboard, so I've tried on occasion using an online scratchpad like codeshare.io with varying degrees of success. And then there's the inability to tell whether the candidate is really grasping questions or problems when you can't see them.

How do you guys deal with this? Any suggestions?
 

Slavik81

Member
The server never returns an error as it sits at the accept() call. The client returns -1 at the connect(). I put in <cerrno> and it says the error is 111 "Connection refused."
After a bit of googling, it seems this error suggests that either there's no server on the other end, or your connection is being blocked by your firewall.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Random question, but the mention of a whiteboard sparked it into my head.
A while ago I created a browser-based digital whiteboard that we use every day at work for drawing out ideas. It's touch based and works fairly well. (we have some large touch screens on the walls)

There's been people that have told me they still prefer a traditional whiteboard though. That the feeling of using a marker on a whiteboard is more satisfying or natural.
It's made me think of the whole digital/analog world change a little bit, and how such simple things like that just do not feel right. Maybe it's the ever so tiny delay that most digital things have, especially in touch tech, or something else. I'm assuming there are people out there getting paid exponentially more than I am to figure these things out.

Ok that was rambling. What are your opinions on the whole using something digitally vs. traditional analog? ie: taking notes, whiteboarding, reading
 
After a bit of googling, it seems this error suggests that either there's no server on the other end, or your connection is being blocked by your firewall.
Yeah, I forgot to specify the IP address the client should connect to. It's working now.

Random question, but the mention of a whiteboard sparked it into my head.
A while ago I created a browser-based digital whiteboard that we use every day at work for drawing out ideas. It's touch based and works fairly well. (we have some large touch screens on the walls)

There's been people that have told me they still prefer a traditional whiteboard though. That the feeling of using a marker on a whiteboard is more satisfying or natural.
It's made me think of the whole digital/analog world change a little bit, and how such simple things like that just do not feel right. Maybe it's the ever so tiny delay that most digital things have, especially in touch tech, or something else. I'm assuming there are people out there getting paid exponentially more than I am to figure these things out.

Ok that was rambling. What are your opinions on the whole using something digitally vs. traditional analog? ie: taking notes, whiteboarding, reading
Yes to the bolded. Smart boards and the like are really cool, but as long as there's delay I'll always prefer a physical whiteboard.
 
Top Bottom