Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,191,145 members, 7,943,111 topics. Date: Sunday, 08 September 2024 at 06:06 AM

Kencas's Posts

Nairaland Forum / Kencas's Profile / Kencas's Posts

(1) (2) (of 2 pages)

Programming / Re: Plz Some One Should Help Me With This Java Questions by kencas: 4:32pm On Aug 04, 2009
Look for Definitive Guide to swing programming by John Zukowski.Its a good guide.Learn on The java 2d API.More info call 08034275706 or email kcjojo8@gmail.com
Programming / Re: Any Socket Programmer In? by kencas: 8:38am On Jul 30, 2009
This is for the server

//socket.c
//Developed by kencas

#include <stdio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <ctype.h>


#define SHMSZ 27

#define MAX 1000
int main(int argc, char *argv[]){
// get port number

int port = atoi(argv[1]);
// perform range check on port number
if( port <= 1024 ){
printf("must use a port above 1024, terminate.\n"wink;
exit(1);
}

// fd and socket params
int sockfd;
struct sockaddr_in my_addr;
struct sockaddr_in client_addr;
socklen_t sin_size;
int backlog = 5;
int optval = 1;
// create socket, test if worked
sockfd = socket(PF_INET, SOCK_STREAM, 0);
if( sockfd < 0 ){
perror("can't create socket, terminate.\n"wink;
exit(1);
}

// make socket re-use able in case of crashes/restarts
int set = setsockopt(sockfd, SOL_SOCKET,SO_REUSEADDR, &optval, sizeof(optval));
if( set == -1 ){
perror("can't do setsockopt function, terminate.\n"wink;
exit(1);
}

my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(port);
// automatically fill with my IP
my_addr.sin_addr.s_addr = INADDR_ANY;
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
// try to bind
sin_size = sizeof(struct sockaddr);

int bind_result = bind(sockfd,(struct sockaddr *)&my_addr,sin_size);
if( bind_result == -1 ){
perror("can't bind, terminate.\n"wink;
exit(1);
}

// try to listen
int listen_result = listen(sockfd,backlog);
if( listen_result == -1 ){
perror("can't listen, terminate.\n"wink;
exit(1);
}
// debug, show state of socket
printf("listening on port [%d] , \n", port );
int new_fd = 0;
char buffer[MAX];
int bytes = -1;
// while forever


while(1){

sin_size = sizeof(struct sockaddr_in);
// accept incoming request
new_fd = accept(sockfd, (struct sockaddr *)&client_addr, &sin_size);
// valid file descriptor?
if( new_fd != -1 ){

// debug
printf("\naccept() connection %s",inet_ntoa(client_addr.sin_addr));
backlog--;
if (!fork()) {
char old[MAX];
int check = 0;
FILE *fp;
fp = fopen("serverLog.txt", "a+"wink;
fprintf(fp, "\naccept() connection %s",inet_ntoa(client_addr.sin_addr));
fclose(fp);
// child doesn't need the listen socket!
close(sockfd);
// read from client

do{
bytes = recv(new_fd, buffer, sizeof(buffer), 0);
if (bytes < 0){
perror("Read socket"wink ;

}else{
printf("%s \n",buffer);
send (new_fd, buffer, bytes, 0) ;
if( strncmp(old,buffer,2)){
check ++ ;
if (check == 3)
break;
}
strcpy(old,buffer);
}

}while (strncmp(buffer, "endn", 4) != 0 || bytes < 0 ) ;
close(new_fd);
// kill the child
exit(0);
}
// parent does not use this!
close(new_fd);
} else {
// non-fatal
perror("could not accept request, but non-fatal, \n"wink;
}
}// end while

printf("Bottom of file, should never get here! \n\n"wink;
return 0;
} // end of main



read the input with any client from the port specified.Client could be Java,.NET etc

Hope this helps

Cheers
Programming / Re: Any Socket Programmer In? by kencas: 8:31am On Jul 30, 2009
I'm a C++ programmer.Do you have knowledge of C/C++?? email kcjojo8@gmail.com or call 08034275706
Programming / Re: A Programmer's Delight by kencas: 5:22pm On Jul 29, 2009
Guy thats a very good idea.Do EFCC know about this siteor the CBN
Programming / Re: Embedded by kencas: 8:34am On Jul 29, 2009
Guy i'm encouraging u

Look at a snippet 4rm my Project

/*
* File: Worker.h
* Author: Kene
*
* Created on July 23, 2009, 3:59 PM
*/


#include <string> // program uses C++ standard string class
#include <iostream>//uses c++ standard I/O functions
#include "Keypad.h"
#include "Controller.h"
#include "Screen.h"
#include "Define.h"

using std::string;
using std::cout;
using std::endl;

class Worker {
public:
Worker()
{


}

void start()//starts the main worker
{
i=0;
int del = DELAY;
keypad.setCharacter('A');
screen.addToScreen(keypad);
cout << "DELAY: "<< DELAY << endl;
cout << "Worker Started"<< endl;
cout << keypad.getCharacter()<< endl;
//while(true)
//{
//if(i>=100000)
//{
// break;
//}

cout << i<< endl;
//cout <<"Data Read: "<< controller.readInput()<< endl;
cout <<"Pointer Address: "<< &keypad<< endl;
screen.renderDigit();
mypad = &keypad;
cout <<"Pointer Value: "<<mypad->getCharacter()<< endl;
//i++;
//}

}


private:

Keypad keypad;
Controller controller;
Screen screen;
int i;
Keypad *mypad;


};

Hope this one encourages u
Programming / Re: Please Post All Your Java Programing Questions Here. by kencas: 3:19pm On Jul 28, 2009
Data abstraction means hiding some data elements of a class from the public

class Student
{
private String regNo;
private String name;

public void setRegno(String regNo)
{
this.regNo= regNo;
}

public String getRegno()
{
return regNo;
}

public void setName(String name)
{
this.name= name;
}

public String getName()
{
return name;
}

}

Hoope this explains the concept
Programming / Re: Collection Of Nigerian Programming Gurus by kencas: 8:45am On Jul 27, 2009
/*
* File: Worker.h
* Author: Kene
*
* Created on July 23, 2009, 3:59 PM
*/


#include <string> // program uses C++ standard string class
#include <iostream>//uses c++ standard I/O functions
#include "Keypad.h"
#include "Controller.h"
#include "Screen.h"
#include "Define.h"

using std::string;
using std::cout;
using std::endl;

class Worker {
public:
Worker()
{


}

void start()//starts the main worker
{
i=0;
int del = DELAY;
keypad.setCharacter('A');
screen.addToScreen(keypad);
cout << "DELAY: "<< DELAY << endl;
cout << "Worker Started"<< endl;
cout << keypad.getCharacter()<< endl;
//while(true)
//{
//if(i>=100000)
//{
// break;
//}

cout << i<< endl;
//cout <<"Data Read: "<< controller.readInput()<< endl;
cout <<"Pointer Address: "<< &keypad<< endl;
screen.renderDigit();
mypad = &keypad;
cout <<"Pointer Value: "<<mypad->getCharacter()<< endl;
//i++;
//}

}


private:

Keypad keypad;
Controller controller;
Screen screen;
int i;
Keypad *mypad;

//struct itimerval it;
};

I'm a C++ Developer call 08034275706
Programming / Re: Embedded by kencas: 8:40am On Jul 27, 2009
I'm also undergoing a research on Embedded System with C++.Email kcjojo8@gmail.com or call 08034275706
Programming / Webservice Client In Nusoap by kencas: 3:14pm On Jul 20, 2009
Do any body know how to read a Java webservice with nusoap?i've tried but its not working
Family / Re: What Makes A Good Wife? by kencas: 12:40pm On Jul 06, 2009
How are U smiley am ok sad
Jokes Etc / Re: The Types Of Women I've Dated Since I Started Programming! by kencas: 2:05pm On Jun 24, 2009
good post
Programming / Re: C++ Or Java: Which Way To Go? by kencas: 8:53am On Jun 19, 2009
Man,U have to look first at what u have in mind, ur area of specialization, and ur ability to stick to problem solving procedures.C++ is good for general programming introduction but Java is gradually overtaking the market. Better still C/C++ is the still the mother of all!!!
Romance / Betrayal Of Trust.please Advice Me! by kencas: 4:26pm On Jun 16, 2009
My babe betrayed my love for her after her promises, her phone went off and i could not see her for two months.Advice me
Programming / Re: C++ Or Java: Which Way To Go? by kencas: 3:37pm On Jun 16, 2009
C++ is good for drivers programming,but every solutin from C++ can also be solved by Java.Java is more good for the market
Sports / Re: Okocha Named Among Fifa’s World Best Midfielders by kencas: 5:13pm On May 26, 2009
Hurray my Bros for making Nigeria proud.Good lesson for upcoming stars like Mikel.He can still achieve that since he had made it in 2005 U-20 World Cup
Programming / Re: Session Tracking In Servlets by kencas: 4:55pm On May 26, 2009
HttpSession session = request.getSession();
session.setAttribute("name","kencas"wink;

dats all
Programming / Re: Programmers Please Help Me Out by kencas: 12:28pm On Apr 08, 2009
For exporting to excel,u need a library to do it.Just call 08034275706.Will help u
Programming / Re: Association Of Programmers In Nigeria by kencas: 11:24am On Mar 30, 2009
Handyx u line is not available.Better still call 08034275706 so we can talk
Programming / Re: Association Of Programmers In Nigeria by kencas: 11:14am On Mar 25, 2009
Handyx, Which site to register?has the association been incorporated?i'm really Interested
Programming / Re: Association Of Programmers In Nigeria by kencas: 4:29pm On Mar 24, 2009
i agree with the last comment.C is the best language as far am concerned.Lets start from here.I don't know whether any researcher in Nigeria have delved into exclusive research like GENETIC PROGRAMMING,GENETIC ALGORITHM,embedded systems,Real-time Interfacing system etc.Lets work together.We have the skills here in Nigeria.
Programming / Re: Association Of Programmers In Nigeria by kencas: 12:40pm On Mar 24, 2009
Handyxinclude me in the list
Programming / Re: Association Of Programmers In Nigeria by kencas: 12:35pm On Mar 24, 2009
Lets kick off please.I have flare for enterprise systems.Please we could choose a date for the initial meeting.If possible i could lead. Consider this guys
Programming / MVC Pattern by kencas: 8:44am On Mar 11, 2009
Hey Developers.Could any one elaborate more on MVC?

(1) (2) (of 2 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.