Change the port number in the following files:
/etc/apache2/sites-enabled/example.com /etc/apache2/ports.conf /etc/apache2/sites-available/defaultFinally, remember to restart apache server:
/etc/init.d/apache2 restart
/etc/apache2/sites-enabled/example.com /etc/apache2/ports.conf /etc/apache2/sites-available/defaultFinally, remember to restart apache server:
/etc/init.d/apache2 restart
import java.io.BufferedInputStream; import java.io.IOException; import java.io.FileOutputStream; import java.io.BufferedOutputStream; import java.net.URL; public class FileDownloader { public static void main(String args[]) { if(args.length != 2 && !(args[0].equals(""))){ System.out.println("Usage: <web-link> <new-filename>"); }else{try{ if((args[0].substring(7,10)).equals("172")) args[0] = "http://cl.thapar.edu/" + args[0].substring(20); System.out.println("FileDownloader: "+args[0]+" "+args[1]); URL url = new URL(args[0]); java.io.BufferedInputStream in = new BufferedInputStream(url.openStream()); java.io.FileOutputStream fos = new FileOutputStream(args[1]+".pdf"); java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024); byte[] data = new byte[1024]; int x=0; while((x=in.read(data,0,1024))>=0) { bout.write(data,0,x); } bout.close(); in.close(); }catch(IOException e){ System.out.println(e.toString()); }} } }
jar cf JarFileToCreate.jar abc.class def.class ...For More details on creating Jar files, see create-jar-file-for-java-app
<?xml version="1.0" encoding="UTF-8"?> <jnlp spec="1.0+" codebase="http://localhost/jnlp" href="MyApp.jnlp"> <information> <title>My App Title</title> <vendor>MonishVendor</vendor> </information> <resources> <!-- Application Resources --> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> <jar href="TestApp.jar" main="true" /> </resources> <application-desc name="DemoName" main-class="GUI_QPDownloader" width="300" height="300"> </application-desc> <update check="background"/> </jnlp>
jar cfm jar-file manifest-addition input-file(s)
Base::func()
template<class T> class Widget; // uses "class" template<typename T> class Widget; // uses "typename"When declaring template parameters, class and typename are interchangeable.
class basic_ios { ... }; class basic_istream: public basic_ios { ... }; class basic_ostream: public basic_ios { ... }; class basic_iostream: public basic_istream, public basic_ostream { ... };
class basic_ios { ... }; class basic_istream: virtual public basic_ios { ... }; class basic_ostream: virtual public basic_ios { ... }; class basic_iostream: public basic_istream, public basic_ostream { ... };But try to avoid virtual inheritance because:
class Widget { private: class WidgetTimer: public Timer { public: virtual void onTick() const; ... }; WidgetTimer timer; ... };In the third alternative's example, we need to redefine onTick() of class Timer.This design is appreciated over private inheritance because 1.the derived classes would not be able to refine onTick(). 2. In case of private inheritance, Widget get compilation dependencies on the definition of class Timer which would force us to #include timer.h Whereas in alternative 3, By defining WidgetTimer class out of the Widget class and placing a pointer to WidgetTimer would require just declaration of WidgetTimer class at the minimum.
class Shape { public: enum ShapeColor { Red, Green, Blue }; void draw(ShapeColor color = Red) const // now non-virtual { doDraw(color); // calls a virtual } ... private: virtual void doDraw(ShapeColor color) const = 0; // the actual work is }; // done in this func class Rectangle: public Shape { public: ... private: virtual void doDraw(ShapeColor color) const; // note lack of a ... // default param val. };prev | next
#ifndef SCHAT_REGISTER_H #define SCHAT_REGISTER_H //SChat_register.h #include "SChat_connect.h" typedef short bool; int* ar;//= (int*) malloc(sizeof(int)); int maxIndex;// = 0; int top;// = -5; bool reg_lock;// = false; void getRegisteredList(){ int i; for(i=0; i<=top; i++) printf("%d\t", ar[i]); printf("\n"); } //call this before using any other function of this library void init(){ ar = (int*) calloc(1, sizeof(int)); if(ar == NULL) Error("malloc error in init"); top = -1; con_init(); maxIndex = 0; reg_lock = false; }
class Airplane { public: virtual void fly(const Airport& destination) = 0; ... }; void Airplane::fly(const Airport& destination) // an implementation of { // a pure virtual function default code for flying an airplane to the given destination } class ModelA: public Airplane { public: virtual void fly(const Airport& destination) { Airplane::fly(destination); } ... }; class ModelB: public Airplane { public: virtual void fly(const Airport& destination) { Airplane::fly(destination); } ... }; class ModelC: public Airplane { public: virtual void fly(const Airport& destination); ... }; void ModelC::fly(const Airport& destination) { ... //code for flying a ModelC airplane to the given destination }
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> void error(const char *msg) { perror(msg); exit(1); } int main(int argc, char *argv[]) { int sockfd, newsockfd, portno; socklen_t clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; if (argc < 2) { fprintf(stderr,"ERROR, no port provided\n"); exit(1); } //STEP1 socket function sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); //STEP2 address structure bzero((char *) &serv_addr, sizeof(serv_addr)); portno = atoi(argv[1]); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); //STEP3 bind function if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) error("ERROR on binding"); //STEP4 listen function listen(sockfd,10); //STEP5 accept and serve clients one by one in iterative fashion while(1){ clilen = sizeof(cli_addr); newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) error("ERROR on accept"); bzero(buffer,256); while( (n=read(newsockfd,buffer,255)) > 0 ){ if (n < 0) error("ERROR reading from socket"); n = write(newsockfd,buffer,n); if (n < 0) error("ERROR writing to socket"); bzero(buffer,256); } close(newsockfd); } close(sockfd); return 0; }Echo Client program:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> void error(const char *msg) { perror(msg); exit(0); } int main(int argc, char *argv[]) { int sockfd, n; struct sockaddr_in serv_addr; struct hostent *server; char buffer[256]; if (argc < 3) { fprintf(stderr,"usage %s hostname port\n", argv[0]); exit(0); } //STEP1 socket function sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); server = gethostbyname(argv[1]); if (server == NULL) { fprintf(stderr,"ERROR, no such host\n"); exit(0); } //STEP2 prepare address structure bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length); serv_addr.sin_port = htons(atoi(argv[2])); //STEP3 connect function: request to server for connection if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) error("ERROR connecting"); //STEP4 read and write to server. while(1){ bzero(buffer,256); fgets(buffer,255,stdin);//read from client stdin if((n=bcmp("exit",buffer,strlen(buffer))==0)){ close(sockfd); return 0; } n = write(sockfd,buffer,strlen(buffer));//write to server if (n < 0) error("ERROR writing to socket"); bzero(buffer,256); n = read(sockfd,buffer,255);//read from server and save it in array buffer if (n < 0) error("ERROR reading from socket"); printf("%s\n",buffer);//write to stdout the buffer's contents } close(sockfd); return 0; }Cheers and try hosting at Linode.
Cheers and try hosting at Linode.
prev | next
Cheers and try hosting at Linode.
prev | next
Cheers and try hosting at Linode.
Operating System: Windows XP SP2
Server: localhost
Sample String from access.log: 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
127.0.0.1
(%h
)HostnameLookups
is set to On
, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such as logresolve
to determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine.
(T) expression // cast expression to be of type T T(expression) // cast expression to be of type T
namespace std { template <> // typical implementation of std::swap; void swap(T& a, T& b) // swaps a's and b's values { T temp(a); a = b; b = temp; } }
class Rational { public: Rational(int numerator = 0, // ctor is deliberately not explicit; int denominator = 1); // allows implicit int-to-Rational conversions int numerator() const; // accessors for numerator and int denominator() const; // denominator const Rational operator*(const Rational& rhs) const; private: ... }; Rational oneEighth(1, 8); Rational oneHalf(1, 2); result = oneHalf * 2; // fine - oneHalf.operator*(2); result = 2 * oneHalf; // error! - 2.operator*(oneHalf);Way2:
class Rational { ... // contains no operator* }; const Rational operator*(const Rational& lhs, // now a non-member const Rational& rhs) // function { return Rational(lhs.numerator() * rhs.numerator(), lhs.denominator() * rhs.denominator()); } Rational oneFourth(1, 4); Rational result; result = oneFourth * 2; // fine result = 2 * oneFourth; // hooray, it works!Result: As multiplication should be commutative, Way2 should be used when type conversions should apply to all parameters.